cariboujs 2.0.4 → 2.0.6
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.
- package/README.md +13 -3
- package/ada/ada2012/AdaLexer.js +486 -316
- package/ada/ada2012/AdaLexerBase.js +25 -0
- package/ada/ada2012/AdaParser.js +4547 -3823
- package/ada/ada2012/AdaParserBase.js +682 -0
- package/ada/ada2012/AdaParserListener.js +36 -0
- package/ada/ada2012/AdaParserVisitor.js +24 -0
- package/ada/ada2012/Symbol.js +20 -0
- package/ada/ada2012/SymbolTable.js +144 -0
- package/ada/ada2012/TypeClassification.js +15 -0
- package/ada/ada2022/AdaLexer.js +699 -0
- package/ada/ada2022/AdaLexerBase.js +25 -0
- package/ada/ada2022/AdaParser.js +37818 -0
- package/ada/ada2022/AdaParserBase.js +686 -0
- package/ada/ada2022/AdaParserListener.js +3024 -0
- package/ada/ada2022/AdaParserVisitor.js +2020 -0
- package/ada/ada2022/Symbol.js +20 -0
- package/ada/ada2022/SymbolTable.js +144 -0
- package/ada/ada2022/TypeClassification.js +15 -0
- package/c/CLexer.js +918 -0
- package/c/CLexerBase.js +96 -0
- package/c/CParser.js +14878 -0
- package/c/CParserBase.js +617 -0
- package/c/CParserListener.js +1062 -0
- package/c/CParserVisitor.js +712 -0
- package/c/ErrorListener.js +50 -0
- package/c/Symbol.js +28 -0
- package/c/SymbolTable.js +220 -0
- package/c/TypeClassification.js +21 -0
- package/cpp/CPP14Parser.js +630 -619
- package/cpp/CPP14ParserListener.js +56 -56
- package/cpp/CPP14ParserVisitor.js +28 -28
- package/csharp/v7/CSharpLexer.js +1339 -0
- package/csharp/v7/CSharpLexerBase.js +332 -0
- package/csharp/v7/CSharpParser.js +29239 -0
- package/csharp/v7/CSharpParserBase.js +48 -0
- package/csharp/v7/CSharpParserListener.js +2304 -0
- package/csharp/v7/CSharpParserVisitor.js +1540 -0
- package/csharp/v8-spec/CSharpLexer.js +1549 -0
- package/csharp/v8-spec/CSharpLexerBase.js +296 -0
- package/csharp/v8-spec/CSharpParser.js +45055 -0
- package/csharp/v8-spec/CSharpParserBase.js +587 -0
- package/csharp/v8-spec/CSharpParserListener.js +3582 -0
- package/csharp/v8-spec/CSharpParserVisitor.js +2392 -0
- package/cypher/CypherParser.js +1171 -780
- package/cypher/CypherParserListener.js +27 -0
- package/cypher/CypherParserVisitor.js +18 -0
- package/geekcode/geekcodeLexer.js +232 -0
- package/geekcode/geekcodeListener.js +81 -0
- package/geekcode/geekcodeParser.js +1516 -0
- package/geekcode/geekcodeVisitor.js +58 -0
- package/gql/GQLLexer.js +2203 -0
- package/gql/GQLListener.js +5499 -0
- package/gql/GQLParser.js +58653 -0
- package/gql/GQLVisitor.js +3670 -0
- package/kotlin/kotlin/KotlinLexer.js +1257 -1247
- package/kotlin/kotlin/KotlinParser.js +3991 -3425
- package/kotlin/kotlin/KotlinParserListener.js +36 -0
- package/kotlin/kotlin/KotlinParserVisitor.js +24 -0
- package/maml/MAMLLexer.js +116 -0
- package/maml/MAMLListener.js +72 -0
- package/maml/MAMLParser.js +935 -0
- package/maml/MAMLVisitor.js +52 -0
- package/odin/odinLexer.js +739 -0
- package/odin/odinListener.js +882 -0
- package/odin/odinParser.js +12189 -0
- package/odin/odinVisitor.js +592 -0
- package/package.json +1 -1
- package/plantUML/PlantUMLLexer.js +215 -316
- package/plantUML/PlantUMLParser.js +1045 -2393
- package/plantUML/PlantUMLParserListener.js +171 -0
- package/plantUML/PlantUMLParserVisitor.js +118 -0
- package/sql/mysql/Oracle/MySQLLexer.js +3689 -3668
- package/sql/mysql/Oracle/MySQLParser.js +4383 -4399
- package/sql/plsql/PlSqlLexer.js +13604 -13587
- package/sql/plsql/PlSqlParser.js +51622 -64188
- package/sql/plsql/PlSqlParserBase.js +30 -0
- package/sql/plsql/PlSqlParserListener.js +36 -9
- package/sql/plsql/PlSqlParserVisitor.js +24 -6
- package/sql/postgresql/PostgreSQLParser.js +91 -91
- package/sql/snowflake/SnowflakeLexer.js +5675 -5497
- package/sql/snowflake/SnowflakeParser.js +27252 -22655
- package/sql/snowflake/SnowflakeParserListener.js +278 -8
- package/sql/snowflake/SnowflakeParserVisitor.js +184 -4
- package/sql/sqlite/SQLiteParser.js +2638 -2301
- package/sql/sqlite/SQLiteParserListener.js +9 -9
- package/sql/sqlite/SQLiteParserVisitor.js +6 -6
- package/sysml-v2/SysMLv2Lexer.js +1047 -0
- package/sysml-v2/SysMLv2Parser.js +51339 -0
- package/sysml-v2/SysMLv2ParserListener.js +4464 -0
- package/sysml-v2/SysMLv2ParserVisitor.js +2980 -0
- package/turtle/TURTLELexer.js +155 -156
- package/vba/vba7_1/vbaLexer.js +1689 -0
- package/vba/vba7_1/vbaParser.js +42797 -0
- package/vba/vba7_1/vbaParserListener.js +3267 -0
- package/vba/vba7_1/vbaParserVisitor.js +2182 -0
- package/vhdl/vhdl2008/vhdl2008Listener.js +9 -0
- package/vhdl/vhdl2008/vhdl2008Parser.js +2840 -2705
- package/vhdl/vhdl2008/vhdl2008Visitor.js +6 -0
- package/wkt/wktLexer.js +177 -148
- package/wkt/wktListener.js +123 -60
- package/wkt/wktParser.js +1802 -1125
- package/wkt/wktVisitor.js +72 -30
- package/plantUML/PlantUMLListener.js +0 -279
- package/plantUML/PlantUMLVisitor.js +0 -190
- /package/scala/{ScalaLexer.js → scala2/ScalaLexer.js} +0 -0
- /package/scala/{ScalaListener.js → scala2/ScalaListener.js} +0 -0
- /package/scala/{ScalaParser.js → scala2/ScalaParser.js} +0 -0
- /package/scala/{ScalaVisitor.js → scala2/ScalaVisitor.js} +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default class Symbol {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.name = "";
|
|
4
|
+
this.classification = new Set();
|
|
5
|
+
this.members = new Map();
|
|
6
|
+
this.parent = null;
|
|
7
|
+
this.predefined = false;
|
|
8
|
+
this.isComposite = false;
|
|
9
|
+
this.definedFile = "";
|
|
10
|
+
this.definedLine = 0;
|
|
11
|
+
this.definedColumn = 0;
|
|
12
|
+
}
|
|
13
|
+
toString() {
|
|
14
|
+
let result = this.name;
|
|
15
|
+
result += " (with classification " + Array.from(this.classification).join(", ") + ")";
|
|
16
|
+
if (this.isComposite) result += " [composite]";
|
|
17
|
+
if (this.definedFile) result += " defined at " + this.definedFile + ":" + this.definedLine + ":" + this.definedColumn;
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import Symbol from './Symbol.js';
|
|
2
|
+
import TypeClassification from './TypeClassification.js';
|
|
3
|
+
|
|
4
|
+
export default class SymbolTable {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.scopeStack = [];
|
|
7
|
+
this.blockCounter = 0;
|
|
8
|
+
|
|
9
|
+
var globalScope = new Symbol();
|
|
10
|
+
globalScope.name = "global";
|
|
11
|
+
globalScope.classification = new Set([TypeClassification.Global_]);
|
|
12
|
+
this.scopeStack.push(globalScope);
|
|
13
|
+
|
|
14
|
+
// Predefined scalar types
|
|
15
|
+
this._defineType("integer", false);
|
|
16
|
+
this._defineType("natural", false);
|
|
17
|
+
this._defineType("positive", false);
|
|
18
|
+
this._defineType("float", false);
|
|
19
|
+
this._defineType("long_float", false);
|
|
20
|
+
this._defineType("character", false);
|
|
21
|
+
this._defineType("wide_character", false);
|
|
22
|
+
this._defineType("wide_wide_character", false);
|
|
23
|
+
this._defineType("boolean", false);
|
|
24
|
+
this._defineType("duration", false);
|
|
25
|
+
|
|
26
|
+
// Predefined composite types
|
|
27
|
+
this._defineType("string", true);
|
|
28
|
+
this._defineType("wide_string", true);
|
|
29
|
+
this._defineType("wide_wide_string", true);
|
|
30
|
+
|
|
31
|
+
// Predefined exceptions
|
|
32
|
+
this._definePredefined("constraint_error", TypeClassification.ExceptionName_);
|
|
33
|
+
this._definePredefined("program_error", TypeClassification.ExceptionName_);
|
|
34
|
+
this._definePredefined("storage_error", TypeClassification.ExceptionName_);
|
|
35
|
+
this._definePredefined("tasking_error", TypeClassification.ExceptionName_);
|
|
36
|
+
this._definePredefined("numeric_error", TypeClassification.ExceptionName_);
|
|
37
|
+
|
|
38
|
+
// Predefined enumeration literals
|
|
39
|
+
this._definePredefined("true", TypeClassification.EnumerationLiteral_);
|
|
40
|
+
this._definePredefined("false", TypeClassification.EnumerationLiteral_);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
_defineType(name, isComposite) {
|
|
44
|
+
var sym = new Symbol();
|
|
45
|
+
sym.name = name;
|
|
46
|
+
sym.classification = new Set([TypeClassification.TypeName_]);
|
|
47
|
+
sym.predefined = true;
|
|
48
|
+
sym.isComposite = isComposite;
|
|
49
|
+
this.define(sym);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
_definePredefined(name, classification) {
|
|
53
|
+
var sym = new Symbol();
|
|
54
|
+
sym.name = name;
|
|
55
|
+
sym.classification = new Set([classification]);
|
|
56
|
+
sym.predefined = true;
|
|
57
|
+
this.define(sym);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
currentScope() {
|
|
61
|
+
if (this.scopeStack.length === 0) return null;
|
|
62
|
+
return this.scopeStack[this.scopeStack.length - 1];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
define(symbol) {
|
|
66
|
+
var currentScope = this.currentScope();
|
|
67
|
+
if (currentScope === null) return false;
|
|
68
|
+
// Case-insensitive: normalize name to lowercase
|
|
69
|
+
symbol.name = symbol.name.toLowerCase();
|
|
70
|
+
if (currentScope.members.has(symbol.name)) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
symbol.parent = currentScope;
|
|
74
|
+
currentScope.members.set(symbol.name, symbol);
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
resolve(name) {
|
|
79
|
+
// Case-insensitive: normalize to lowercase
|
|
80
|
+
name = name.toLowerCase();
|
|
81
|
+
for (var i = this.scopeStack.length - 1; i >= 0; i--) {
|
|
82
|
+
var scope = this.scopeStack[i];
|
|
83
|
+
if (scope.members.has(name)) {
|
|
84
|
+
return scope.members.get(name);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
pushBlockScope() {
|
|
91
|
+
var blockScope = new Symbol();
|
|
92
|
+
blockScope.name = "block" + (++this.blockCounter);
|
|
93
|
+
blockScope.classification = new Set([TypeClassification.Block_]);
|
|
94
|
+
blockScope.predefined = true;
|
|
95
|
+
var current = this.currentScope();
|
|
96
|
+
if (current !== null && blockScope !== current) {
|
|
97
|
+
this.scopeStack.push(blockScope);
|
|
98
|
+
}
|
|
99
|
+
return blockScope;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
popBlockScope() {
|
|
103
|
+
if (this.scopeStack.length <= 1) {
|
|
104
|
+
throw new Error("SymbolTable: scope stack underflow");
|
|
105
|
+
}
|
|
106
|
+
this.scopeStack.pop();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
getExportedSymbols() {
|
|
110
|
+
var result = [];
|
|
111
|
+
if (this.scopeStack.length === 0) return result;
|
|
112
|
+
var global = this.scopeStack[0]; // bottom of stack = global scope
|
|
113
|
+
for (var [key, sym] of global.members) {
|
|
114
|
+
if (!sym.predefined) {
|
|
115
|
+
result.push(sym);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
toString() {
|
|
122
|
+
var result = "";
|
|
123
|
+
if (this.scopeStack.length > 0) {
|
|
124
|
+
result = this._toStringHelper(this.scopeStack[0], 0);
|
|
125
|
+
}
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
_toStringHelper(scope, depth) {
|
|
130
|
+
var result = "";
|
|
131
|
+
var indent = " ".repeat(depth);
|
|
132
|
+
for (var [key, sym] of scope.members) {
|
|
133
|
+
if (!sym.predefined) {
|
|
134
|
+
result += indent + sym.toString() + "\n";
|
|
135
|
+
}
|
|
136
|
+
if (sym.classification.has(TypeClassification.Block_) ||
|
|
137
|
+
sym.classification.has(TypeClassification.SubprogramName_) ||
|
|
138
|
+
sym.classification.has(TypeClassification.PackageName_)) {
|
|
139
|
+
result += this._toStringHelper(sym, depth + 1);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const TypeClassification = Object.freeze({
|
|
2
|
+
Global_: 'Global_',
|
|
3
|
+
Block_: 'Block_',
|
|
4
|
+
TypeName_: 'TypeName_',
|
|
5
|
+
ObjectName_: 'ObjectName_',
|
|
6
|
+
SubprogramName_: 'SubprogramName_',
|
|
7
|
+
PackageName_: 'PackageName_',
|
|
8
|
+
ExceptionName_: 'ExceptionName_',
|
|
9
|
+
GenericName_: 'GenericName_',
|
|
10
|
+
EnumerationLiteral_: 'EnumerationLiteral_',
|
|
11
|
+
ComponentName_: 'ComponentName_',
|
|
12
|
+
LabelName_: 'LabelName_',
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export default TypeClassification;
|