cariboujs 2.0.3 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +330 -324
  2. package/ada/ada2012/AdaLexer.js +486 -316
  3. package/ada/ada2012/AdaLexerBase.js +25 -0
  4. package/ada/ada2012/AdaParser.js +4547 -3823
  5. package/ada/ada2012/AdaParserBase.js +682 -0
  6. package/ada/ada2012/AdaParserListener.js +36 -0
  7. package/ada/ada2012/AdaParserVisitor.js +24 -0
  8. package/ada/ada2012/Symbol.js +20 -0
  9. package/ada/ada2012/SymbolTable.js +144 -0
  10. package/ada/ada2012/TypeClassification.js +15 -0
  11. package/ada/ada2022/AdaLexer.js +699 -0
  12. package/ada/ada2022/AdaLexerBase.js +25 -0
  13. package/ada/ada2022/AdaParser.js +37818 -0
  14. package/ada/ada2022/AdaParserBase.js +686 -0
  15. package/ada/ada2022/AdaParserListener.js +3024 -0
  16. package/ada/ada2022/AdaParserVisitor.js +2020 -0
  17. package/ada/ada2022/Symbol.js +20 -0
  18. package/ada/ada2022/SymbolTable.js +144 -0
  19. package/ada/ada2022/TypeClassification.js +15 -0
  20. package/c/CLexer.js +846 -603
  21. package/c/CLexerBase.js +96 -0
  22. package/c/CParser.js +8798 -4776
  23. package/c/CParserBase.js +591 -0
  24. package/c/{CListener.js → CParserListener.js} +382 -112
  25. package/c/{CVisitor.js → CParserVisitor.js} +252 -72
  26. package/c/ErrorListener.js +50 -0
  27. package/c/Symbol.js +28 -0
  28. package/c/SymbolTable.js +215 -0
  29. package/c/TypeClassification.js +21 -0
  30. package/cpp/CPP14Parser.js +215 -215
  31. package/cpp/CPP14ParserListener.js +56 -56
  32. package/cpp/CPP14ParserVisitor.js +28 -28
  33. package/cql3/CqlLexer.js +708 -692
  34. package/cql3/CqlParser.js +3356 -2802
  35. package/cql3/CqlParserListener.js +36 -0
  36. package/cql3/CqlParserVisitor.js +24 -0
  37. package/csharp/v7/CSharpLexer.js +1339 -0
  38. package/csharp/v7/CSharpLexerBase.js +332 -0
  39. package/csharp/v7/CSharpParser.js +29239 -0
  40. package/csharp/v7/CSharpParserBase.js +48 -0
  41. package/csharp/v7/CSharpParserListener.js +2304 -0
  42. package/csharp/v7/CSharpParserVisitor.js +1540 -0
  43. package/csharp/v8-spec/CSharpLexer.js +1549 -0
  44. package/csharp/v8-spec/CSharpLexerBase.js +296 -0
  45. package/csharp/v8-spec/CSharpParser.js +45044 -0
  46. package/csharp/v8-spec/CSharpParserBase.js +569 -0
  47. package/csharp/v8-spec/CSharpParserListener.js +3582 -0
  48. package/csharp/v8-spec/CSharpParserVisitor.js +2392 -0
  49. package/geekcode/geekcodeLexer.js +232 -0
  50. package/geekcode/geekcodeListener.js +81 -0
  51. package/geekcode/geekcodeParser.js +1516 -0
  52. package/geekcode/geekcodeVisitor.js +58 -0
  53. package/kotlin/kotlin/KotlinLexer.js +1257 -1247
  54. package/kotlin/kotlin/KotlinParser.js +3991 -3425
  55. package/kotlin/kotlin/KotlinParserListener.js +36 -0
  56. package/kotlin/kotlin/KotlinParserVisitor.js +24 -0
  57. package/package.json +1 -1
  58. package/plantUML/PlantUMLLexer.js +215 -316
  59. package/plantUML/PlantUMLParser.js +1045 -2393
  60. package/plantUML/PlantUMLParserListener.js +171 -0
  61. package/plantUML/PlantUMLParserVisitor.js +118 -0
  62. package/sql/cockroachdb/CockroachDBLexer.js +3865 -0
  63. package/sql/cockroachdb/CockroachDBParser.js +123259 -0
  64. package/sql/cockroachdb/CockroachDBParserListener.js +7281 -0
  65. package/sql/cockroachdb/CockroachDBParserVisitor.js +4858 -0
  66. package/sql/plsql/PlSqlParser.js +27187 -42911
  67. package/sql/plsql/PlSqlParserBase.js +30 -0
  68. package/sql/plsql/PlSqlParserListener.js +0 -9
  69. package/sql/plsql/PlSqlParserVisitor.js +0 -6
  70. package/sql/snowflake/SnowflakeLexer.js +5675 -5497
  71. package/sql/snowflake/SnowflakeParser.js +27230 -22653
  72. package/sql/snowflake/SnowflakeParserListener.js +278 -8
  73. package/sql/snowflake/SnowflakeParserVisitor.js +184 -4
  74. package/sql/sqlite/SQLiteParser.js +1115 -1115
  75. package/sql/sqlite/SQLiteParserListener.js +9 -9
  76. package/sql/sqlite/SQLiteParserVisitor.js +6 -6
  77. package/sysml-v2/SysMLv2Lexer.js +1047 -0
  78. package/sysml-v2/SysMLv2Parser.js +51339 -0
  79. package/sysml-v2/SysMLv2ParserListener.js +4464 -0
  80. package/sysml-v2/SysMLv2ParserVisitor.js +2980 -0
  81. package/plantUML/PlantUMLListener.js +0 -279
  82. package/plantUML/PlantUMLVisitor.js +0 -190
@@ -0,0 +1,215 @@
1
+ import { Symbol } from "./Symbol.js";
2
+ import { TypeClassification } from "./TypeClassification.js";
3
+
4
+ export class SymbolTable {
5
+ constructor() {
6
+ this.scopeStack = [];
7
+ this.blockCounter = 0;
8
+
9
+ const globalScope = this._createSymbol("global", TypeClassification.Global_);
10
+ this.scopeStack.push(globalScope);
11
+
12
+ this.define(this._createSymbol("auto", TypeClassification.StorageClassSpecifier_));
13
+ this.define(this._createSymbol("constexpr", TypeClassification.StorageClassSpecifier_));
14
+ this.define(this._createSymbol("extern", TypeClassification.StorageClassSpecifier_));
15
+ this.define(this._createSymbol("register", TypeClassification.StorageClassSpecifier_));
16
+ this.define(this._createSymbol("static", TypeClassification.StorageClassSpecifier_));
17
+ this.define(this._createSymbol("thread_local", TypeClassification.StorageClassSpecifier_));
18
+ this.define(this._createSymbol("_Thread_local", TypeClassification.StorageClassSpecifier_));
19
+ this.define(this._createSymbol("typedef", TypeClassification.StorageClassSpecifier_));
20
+
21
+ this.define(this._createSymbol("enum", TypeClassification.EnumSpecifier_));
22
+
23
+ this.define(this._createSymbol("struct", TypeClassification.StorageClassSpecifier_));
24
+ this.define(this._createSymbol("union", TypeClassification.StorageClassSpecifier_));
25
+
26
+ this.define(this._createSymbol("const", TypeClassification.TypeQualifier_));
27
+ this.define(this._createSymbol("restrict", TypeClassification.TypeQualifier_));
28
+ this.define(this._createSymbol("volatile", TypeClassification.TypeQualifier_));
29
+ this.define(this._createSymbolMulti("_Atomic", TypeClassification.TypeQualifier_, TypeClassification.AtomicTypeSpecifier_));
30
+
31
+ this.define(this._createSymbol("void", TypeClassification.TypeSpecifier_));
32
+ this.define(this._createSymbol("char", TypeClassification.TypeSpecifier_));
33
+ this.define(this._createSymbol("short", TypeClassification.TypeSpecifier_));
34
+ this.define(this._createSymbol("int", TypeClassification.TypeSpecifier_));
35
+ this.define(this._createSymbol("long", TypeClassification.TypeSpecifier_));
36
+ this.define(this._createSymbol("float", TypeClassification.TypeSpecifier_));
37
+ this.define(this._createSymbol("double", TypeClassification.TypeSpecifier_));
38
+ this.define(this._createSymbol("signed", TypeClassification.TypeSpecifier_));
39
+ this.define(this._createSymbol("unsigned", TypeClassification.TypeSpecifier_));
40
+ this.define(this._createSymbol("_BitInt", TypeClassification.TypeSpecifier_));
41
+ this.define(this._createSymbol("bool", TypeClassification.TypeSpecifier_));
42
+ this.define(this._createSymbol("_Bool", TypeClassification.TypeSpecifier_));
43
+ this.define(this._createSymbol("_Complex", TypeClassification.TypeSpecifier_));
44
+ this.define(this._createSymbol("_Decimal32", TypeClassification.TypeSpecifier_));
45
+ this.define(this._createSymbol("_Decimal64", TypeClassification.TypeSpecifier_));
46
+ this.define(this._createSymbol("_Decimal128", TypeClassification.TypeSpecifier_));
47
+ this.define(this._createSymbol("__m128", TypeClassification.TypeSpecifier_));
48
+ this.define(this._createSymbol("__m128d", TypeClassification.TypeSpecifier_));
49
+ this.define(this._createSymbol("__m128i", TypeClassification.TypeSpecifier_));
50
+ this.define(this._createSymbol("__extension__", TypeClassification.TypeSpecifier_));
51
+
52
+ this.define(this._createSymbol("__builtin_va_list", TypeClassification.TypeSpecifier_));
53
+ this.define(this._createSymbol("__builtin_has_attribute", TypeClassification.TypeSpecifier_));
54
+ this.define(this._createSymbol("__builtin_speculation_safe_value", TypeClassification.TypeSpecifier_));
55
+ this.define(this._createSymbol("__builtin_types_compatible_p", TypeClassification.TypeSpecifier_));
56
+ this.define(this._createSymbol("__builtin_choose_expr", TypeClassification.TypeSpecifier_));
57
+ this.define(this._createSymbol("__builtin_tgmath", TypeClassification.TypeSpecifier_));
58
+ this.define(this._createSymbol("__builtin_constant_p", TypeClassification.TypeSpecifier_));
59
+ this.define(this._createSymbol("__builtin_is_constant_evaluated", TypeClassification.TypeSpecifier_));
60
+ this.define(this._createSymbol("__builtin_bit_cast", TypeClassification.TypeSpecifier_));
61
+ this.define(this._createSymbol("__builtin_expect", TypeClassification.TypeSpecifier_));
62
+ this.define(this._createSymbol("__builtin_expect_with_probability", TypeClassification.TypeSpecifier_));
63
+ this.define(this._createSymbol("__builtin_trap", TypeClassification.TypeSpecifier_));
64
+ this.define(this._createSymbol("__builtin_assoc_barrier", TypeClassification.TypeSpecifier_));
65
+ this.define(this._createSymbol("__builtin_assume_aligned", TypeClassification.TypeSpecifier_));
66
+ this.define(this._createSymbol("__builtin_LINE", TypeClassification.TypeSpecifier_));
67
+ this.define(this._createSymbol("__builtin_FUNCTION", TypeClassification.TypeSpecifier_));
68
+ this.define(this._createSymbol("__builtin_FILE", TypeClassification.TypeSpecifier_));
69
+ this.define(this._createSymbol("__builtin___clear_cache", TypeClassification.TypeSpecifier_));
70
+ this.define(this._createSymbol("__builtin_prefetch", TypeClassification.Function_));
71
+ this.define(this._createSymbol("__builtin_classify_type", TypeClassification.TypeSpecifier_));
72
+ this.define(this._createSymbol("__builtin_extend_pointer", TypeClassification.TypeSpecifier_));
73
+ this.define(this._createSymbol("__builtin_goacc_parlevel_id", TypeClassification.TypeSpecifier_));
74
+ this.define(this._createSymbol("__builtin_goacc_parlevel_size", TypeClassification.TypeSpecifier_));
75
+
76
+ this.define(this._createSymbol("inline", TypeClassification.FunctionSpecifier_));
77
+ this.define(this._createSymbol("_Noreturn", TypeClassification.FunctionSpecifier_));
78
+ this.define(this._createSymbol("__inline__", TypeClassification.FunctionSpecifier_));
79
+
80
+ this.define(this._createSymbol("__cdecl", TypeClassification.FunctionSpecifier_));
81
+ this.define(this._createSymbol("__clrcall", TypeClassification.FunctionSpecifier_));
82
+ this.define(this._createSymbol("__stdcall", TypeClassification.FunctionSpecifier_));
83
+ this.define(this._createSymbol("__fastcall", TypeClassification.FunctionSpecifier_));
84
+ this.define(this._createSymbol("__thiscall", TypeClassification.FunctionSpecifier_));
85
+ this.define(this._createSymbol("__vectorcall", TypeClassification.FunctionSpecifier_));
86
+
87
+ this.define(this._createSymbol("_purecall", TypeClassification.TypeSpecifier_));
88
+ this.define(this._createSymbol("_purecall_handler", TypeClassification.TypeSpecifier_));
89
+ this.define(this._createSymbol("_onexit_t", TypeClassification.TypeSpecifier_));
90
+ this.define(this._createSymbol("_locale_t", TypeClassification.TypeSpecifier_));
91
+ this.define(this._createSymbol("_invalid_parameter_handler", TypeClassification.TypeSpecifier_));
92
+ this.define(this._createSymbol("__inline", TypeClassification.TypeSpecifier_));
93
+
94
+ this.define(this._createSymbol("__int8", TypeClassification.TypeSpecifier_));
95
+ this.define(this._createSymbol("__int16", TypeClassification.TypeSpecifier_));
96
+ this.define(this._createSymbol("__int32", TypeClassification.TypeSpecifier_));
97
+ this.define(this._createSymbol("__int64", TypeClassification.TypeSpecifier_));
98
+ this.define(this._createSymbol("__int128", TypeClassification.TypeSpecifier_));
99
+ this.define(this._createSymbol("_Float16", TypeClassification.TypeSpecifier_));
100
+ this.define(this._createSymbol("_Float32", TypeClassification.TypeSpecifier_));
101
+ this.define(this._createSymbol("_Float64", TypeClassification.TypeSpecifier_));
102
+ this.define(this._createSymbol("_Float128", TypeClassification.TypeSpecifier_));
103
+ this.define(this._createSymbol("__v8hf", TypeClassification.TypeSpecifier_));
104
+ this.define(this._createSymbol("__bf16", TypeClassification.TypeSpecifier_));
105
+ this.define(this._createSymbol("__v16bf", TypeClassification.TypeSpecifier_));
106
+
107
+ this.define(this._createSymbol("__declspec", TypeClassification.FunctionSpecifier_));
108
+ this.define(this._createSymbol("__attribute__", TypeClassification.FunctionSpecifier_));
109
+
110
+ this.define(this._createSymbol("alignas", TypeClassification.AlignmentSpecifier_));
111
+ this.define(this._createSymbol("align", TypeClassification.AlignmentSpecifier_));
112
+ }
113
+
114
+ _createSymbol(name, classification) {
115
+ const symbol = new Symbol();
116
+ symbol.name = name;
117
+ symbol.classification = new Set([classification]);
118
+ symbol.predefined = true;
119
+ return symbol;
120
+ }
121
+
122
+ _createSymbolMulti(name, ...classifications) {
123
+ const symbol = new Symbol();
124
+ symbol.name = name;
125
+ symbol.classification = new Set(classifications);
126
+ symbol.predefined = true;
127
+ return symbol;
128
+ }
129
+
130
+ enterScope(newScope) {
131
+ const current = this.scopeStack[this.scopeStack.length - 1];
132
+ if (newScope === current) return;
133
+ this.scopeStack.push(newScope);
134
+ }
135
+
136
+ exitScope() {
137
+ this.scopeStack.pop();
138
+ if (this.scopeStack.length === 0) {
139
+ throw new Error("Cannot exit global scope");
140
+ }
141
+ }
142
+
143
+ currentScope() {
144
+ if (this.scopeStack.length === 0) return null;
145
+ return this.scopeStack[this.scopeStack.length - 1];
146
+ }
147
+
148
+ define(symbol) {
149
+ const currentScope = this.currentScope();
150
+ if (!currentScope) return false;
151
+ return this.defineInScope(currentScope, symbol);
152
+ }
153
+
154
+ defineInScope(currentScope, symbol) {
155
+ if (currentScope.members.has(symbol.name)) {
156
+ return false;
157
+ }
158
+ symbol.parent = currentScope;
159
+ currentScope.members.set(symbol.name, symbol);
160
+ return true;
161
+ }
162
+
163
+ resolve(name, startScope = null) {
164
+ if (startScope === null) {
165
+ for (let i = this.scopeStack.length - 1; i >= 0; i--) {
166
+ const scope = this.scopeStack[i];
167
+ const symbol = scope.members.get(name);
168
+ if (symbol) {
169
+ return symbol;
170
+ }
171
+ }
172
+ return null;
173
+ } else {
174
+ return startScope.members.get(name) || null;
175
+ }
176
+ }
177
+
178
+ pushBlockScope() {
179
+ const blockScope = new Symbol();
180
+ blockScope.name = "block" + (++this.blockCounter);
181
+ blockScope.classification = new Set([TypeClassification.Block_]);
182
+ blockScope.predefined = true;
183
+ this.enterScope(blockScope);
184
+ return blockScope;
185
+ }
186
+
187
+ popBlockScope() {
188
+ this.exitScope();
189
+ }
190
+
191
+ toString() {
192
+ let result = "";
193
+ if (this.scopeStack.length > 0) {
194
+ result = this._toStringHelper(this.scopeStack[0], 0);
195
+ }
196
+ return result;
197
+ }
198
+
199
+ _toStringHelper(scope, depth) {
200
+ let result = "";
201
+ const indent = " ".repeat(depth);
202
+ for (const [key, sym] of scope.members) {
203
+ if (!sym.predefined) {
204
+ result += indent + sym.toString() + "\n";
205
+ }
206
+ if (sym.classification.has(TypeClassification.Block_) ||
207
+ sym.classification.has(TypeClassification.Function_)) {
208
+ result += this._toStringHelper(sym, depth + 1);
209
+ }
210
+ }
211
+ return result;
212
+ }
213
+ }
214
+
215
+ export default SymbolTable;
@@ -0,0 +1,21 @@
1
+ const TypeClassification = Object.freeze({
2
+ Global_: 0,
3
+ Block_: 1,
4
+ Function_: 2,
5
+ Variable_: 3,
6
+ TypeSpecifier_: 4,
7
+ StorageClassSpecifier_: 5,
8
+ TypeQualifier_: 6,
9
+ FunctionSpecifier_: 7,
10
+ AlignmentSpecifier_: 8,
11
+ AtomicTypeSpecifier_: 9,
12
+ EnumSpecifier_: 10
13
+ });
14
+
15
+ // Reverse mapping for toString
16
+ const TypeClassificationNames = Object.freeze(
17
+ Object.fromEntries(Object.entries(TypeClassification).map(([k, v]) => [v, k]))
18
+ );
19
+
20
+ export { TypeClassification, TypeClassificationNames };
21
+ export default TypeClassification;