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.
Files changed (109) hide show
  1. package/README.md +13 -3
  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 +918 -0
  21. package/c/CLexerBase.js +96 -0
  22. package/c/CParser.js +14878 -0
  23. package/c/CParserBase.js +617 -0
  24. package/c/CParserListener.js +1062 -0
  25. package/c/CParserVisitor.js +712 -0
  26. package/c/ErrorListener.js +50 -0
  27. package/c/Symbol.js +28 -0
  28. package/c/SymbolTable.js +220 -0
  29. package/c/TypeClassification.js +21 -0
  30. package/cpp/CPP14Parser.js +630 -619
  31. package/cpp/CPP14ParserListener.js +56 -56
  32. package/cpp/CPP14ParserVisitor.js +28 -28
  33. package/csharp/v7/CSharpLexer.js +1339 -0
  34. package/csharp/v7/CSharpLexerBase.js +332 -0
  35. package/csharp/v7/CSharpParser.js +29239 -0
  36. package/csharp/v7/CSharpParserBase.js +48 -0
  37. package/csharp/v7/CSharpParserListener.js +2304 -0
  38. package/csharp/v7/CSharpParserVisitor.js +1540 -0
  39. package/csharp/v8-spec/CSharpLexer.js +1549 -0
  40. package/csharp/v8-spec/CSharpLexerBase.js +296 -0
  41. package/csharp/v8-spec/CSharpParser.js +45055 -0
  42. package/csharp/v8-spec/CSharpParserBase.js +587 -0
  43. package/csharp/v8-spec/CSharpParserListener.js +3582 -0
  44. package/csharp/v8-spec/CSharpParserVisitor.js +2392 -0
  45. package/cypher/CypherParser.js +1171 -780
  46. package/cypher/CypherParserListener.js +27 -0
  47. package/cypher/CypherParserVisitor.js +18 -0
  48. package/geekcode/geekcodeLexer.js +232 -0
  49. package/geekcode/geekcodeListener.js +81 -0
  50. package/geekcode/geekcodeParser.js +1516 -0
  51. package/geekcode/geekcodeVisitor.js +58 -0
  52. package/gql/GQLLexer.js +2203 -0
  53. package/gql/GQLListener.js +5499 -0
  54. package/gql/GQLParser.js +58653 -0
  55. package/gql/GQLVisitor.js +3670 -0
  56. package/kotlin/kotlin/KotlinLexer.js +1257 -1247
  57. package/kotlin/kotlin/KotlinParser.js +3991 -3425
  58. package/kotlin/kotlin/KotlinParserListener.js +36 -0
  59. package/kotlin/kotlin/KotlinParserVisitor.js +24 -0
  60. package/maml/MAMLLexer.js +116 -0
  61. package/maml/MAMLListener.js +72 -0
  62. package/maml/MAMLParser.js +935 -0
  63. package/maml/MAMLVisitor.js +52 -0
  64. package/odin/odinLexer.js +739 -0
  65. package/odin/odinListener.js +882 -0
  66. package/odin/odinParser.js +12189 -0
  67. package/odin/odinVisitor.js +592 -0
  68. package/package.json +1 -1
  69. package/plantUML/PlantUMLLexer.js +215 -316
  70. package/plantUML/PlantUMLParser.js +1045 -2393
  71. package/plantUML/PlantUMLParserListener.js +171 -0
  72. package/plantUML/PlantUMLParserVisitor.js +118 -0
  73. package/sql/mysql/Oracle/MySQLLexer.js +3689 -3668
  74. package/sql/mysql/Oracle/MySQLParser.js +4383 -4399
  75. package/sql/plsql/PlSqlLexer.js +13604 -13587
  76. package/sql/plsql/PlSqlParser.js +51622 -64188
  77. package/sql/plsql/PlSqlParserBase.js +30 -0
  78. package/sql/plsql/PlSqlParserListener.js +36 -9
  79. package/sql/plsql/PlSqlParserVisitor.js +24 -6
  80. package/sql/postgresql/PostgreSQLParser.js +91 -91
  81. package/sql/snowflake/SnowflakeLexer.js +5675 -5497
  82. package/sql/snowflake/SnowflakeParser.js +27252 -22655
  83. package/sql/snowflake/SnowflakeParserListener.js +278 -8
  84. package/sql/snowflake/SnowflakeParserVisitor.js +184 -4
  85. package/sql/sqlite/SQLiteParser.js +2638 -2301
  86. package/sql/sqlite/SQLiteParserListener.js +9 -9
  87. package/sql/sqlite/SQLiteParserVisitor.js +6 -6
  88. package/sysml-v2/SysMLv2Lexer.js +1047 -0
  89. package/sysml-v2/SysMLv2Parser.js +51339 -0
  90. package/sysml-v2/SysMLv2ParserListener.js +4464 -0
  91. package/sysml-v2/SysMLv2ParserVisitor.js +2980 -0
  92. package/turtle/TURTLELexer.js +155 -156
  93. package/vba/vba7_1/vbaLexer.js +1689 -0
  94. package/vba/vba7_1/vbaParser.js +42797 -0
  95. package/vba/vba7_1/vbaParserListener.js +3267 -0
  96. package/vba/vba7_1/vbaParserVisitor.js +2182 -0
  97. package/vhdl/vhdl2008/vhdl2008Listener.js +9 -0
  98. package/vhdl/vhdl2008/vhdl2008Parser.js +2840 -2705
  99. package/vhdl/vhdl2008/vhdl2008Visitor.js +6 -0
  100. package/wkt/wktLexer.js +177 -148
  101. package/wkt/wktListener.js +123 -60
  102. package/wkt/wktParser.js +1802 -1125
  103. package/wkt/wktVisitor.js +72 -30
  104. package/plantUML/PlantUMLListener.js +0 -279
  105. package/plantUML/PlantUMLVisitor.js +0 -190
  106. /package/scala/{ScalaLexer.js → scala2/ScalaLexer.js} +0 -0
  107. /package/scala/{ScalaListener.js → scala2/ScalaListener.js} +0 -0
  108. /package/scala/{ScalaParser.js → scala2/ScalaParser.js} +0 -0
  109. /package/scala/{ScalaVisitor.js → scala2/ScalaVisitor.js} +0 -0
@@ -0,0 +1,96 @@
1
+ import antlr4 from 'antlr4';
2
+ import { execSync } from 'child_process';
3
+ import * as fs from 'fs';
4
+
5
+ export default class CLexerBase extends antlr4.Lexer {
6
+ constructor(input) {
7
+ super(CLexerBase.runGccAndMakeStream(input));
8
+ }
9
+
10
+ static runGccAndMakeStream(input) {
11
+ const isWindows = process.platform === "win32";
12
+
13
+ const args = process.argv;
14
+
15
+ const vsc = args.some(a => a.toLowerCase().includes("--vsc"));
16
+ let gcc = args.some(a => a.toLowerCase().includes("--gcc"));
17
+ const clang = args.some(a => a.toLowerCase().includes("--clang"));
18
+ const nopp = args.some(a => a.toLowerCase().includes("--nopp"));
19
+
20
+ if (!(vsc || gcc || clang)) {
21
+ gcc = true;
22
+ }
23
+
24
+ const ppOptions = CLexerBase.extractPreprocessorOptions(args);
25
+
26
+ let sourceName = input.name;
27
+ const inputText = input.getText(0, input.size - 1);
28
+
29
+ if (!sourceName || sourceName === "" || !sourceName.endsWith(".c")) {
30
+ sourceName = "stdin.c";
31
+ }
32
+
33
+ const outputName = sourceName + ".p";
34
+
35
+ if (nopp) {
36
+ try {
37
+ fs.writeFileSync(outputName, inputText);
38
+ } catch (e) {
39
+ // Ignore
40
+ }
41
+ return antlr4.CharStreams.fromString(inputText);
42
+ }
43
+
44
+ if (sourceName === "stdin.c") {
45
+ fs.writeFileSync(sourceName, inputText);
46
+ }
47
+
48
+ if (gcc) {
49
+ let output = "";
50
+ try {
51
+ const gccCommand = isWindows ? "gcc.exe" : "gcc";
52
+ const ppOptsStr = ppOptions.map(o => `"${o}"`).join(" ");
53
+ output = execSync(`${gccCommand} -std=c2x -E -C ${ppOptsStr} "${sourceName}"`, {
54
+ encoding: "utf-8",
55
+ maxBuffer: 50 * 1024 * 1024,
56
+ stdio: ["ignore", "pipe", "pipe"],
57
+ });
58
+ } catch (e) {
59
+ // Ignore
60
+ }
61
+ fs.writeFileSync(outputName, output);
62
+ return antlr4.CharStreams.fromString(output);
63
+ }
64
+ if (clang) {
65
+ let output = "";
66
+ try {
67
+ const clangCommand = isWindows ? "clang.exe" : "clang";
68
+ const ppOptsStr = ppOptions.map(o => `"${o}"`).join(" ");
69
+ output = execSync(`${clangCommand} -std=c2x -E -C ${ppOptsStr} "${sourceName}"`, {
70
+ encoding: "utf-8",
71
+ maxBuffer: 50 * 1024 * 1024,
72
+ stdio: ["ignore", "pipe", "pipe"],
73
+ });
74
+ } catch (e) {
75
+ // Ignore
76
+ }
77
+ fs.writeFileSync(outputName, output);
78
+ return antlr4.CharStreams.fromString(output);
79
+ }
80
+
81
+ throw new Error("No preprocessor specified.");
82
+ }
83
+
84
+ static extractPreprocessorOptions(args) {
85
+ const options = [];
86
+ for (const arg of args) {
87
+ if (arg.startsWith("--D")) {
88
+ options.push("-D" + arg.substring(3));
89
+ }
90
+ else if (arg.startsWith("--I")) {
91
+ options.push("-I" + arg.substring(3));
92
+ }
93
+ }
94
+ return options;
95
+ }
96
+ }