PageRenderTime 43ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/SymbolTable.cs

https://bitbucket.org/cvillamor/compiler
C# | 78 lines | 63 code | 9 blank | 6 comment | 1 complexity | eb480a9c8c5f54c0f8aade232bd9d096 MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace Compiler_
  6. {
  7. //TK_A_VAR type
  8. class Record
  9. {
  10. public bool array;
  11. public TYPE TYPE;
  12. public TOKEN_TYPES TYPE_LT;
  13. public object value;
  14. public int address;
  15. }
  16. //TK_LABEL type
  17. class LabelRecord : Record
  18. {
  19. public bool seen;
  20. public bool local;
  21. public Dictionary<string, GotoRecord> GOTO_RECORDS;
  22. public string scope;
  23. }
  24. //GOTO Scope
  25. class GotoRecord : Record
  26. {
  27. public int hole;
  28. public string scope;
  29. public string secRef;
  30. }
  31. //Array
  32. class ArrayRecord : Record
  33. {
  34. public ArrayRecord(int l, int h, TYPE t, int s)
  35. {
  36. lo = l;
  37. hi = h;
  38. size = s;
  39. eltype = t;
  40. }
  41. public int size;
  42. public int hi;
  43. public int lo;
  44. public TYPE eltype;
  45. public void SetSize() { size = hi-lo+1; }
  46. }
  47. //System Calls
  48. class SystemCallRecord : Record
  49. {
  50. public SystemCallRecord(string name, TOKEN_TYPES tt, int procNum)
  51. {
  52. this.name = name;
  53. base.value = procNum;
  54. base.TYPE_LT = tt;
  55. base.TYPE = (tt == TOKEN_TYPES.TK_SYS_FUNC) ? TYPE.SysFunc : TYPE.SysProc;
  56. }
  57. public string name;
  58. }
  59. //Procedure
  60. class ProcedureRecord : Record
  61. {
  62. public ProcedureRecord(int address)
  63. {
  64. base.TYPE_LT = TOKEN_TYPES.TK_PROCEDURE;
  65. base.TYPE = TYPE.Procedure;
  66. base.address = address;
  67. }
  68. }
  69. }