@dbml/core 2.5.3 → 2.6.0

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 (30) hide show
  1. package/README.md +1 -1
  2. package/lib/model_structure/field.js +3 -1
  3. package/lib/parse/ANTLR/ASTGeneration/AST.js +246 -0
  4. package/lib/parse/ANTLR/ASTGeneration/ParserErrorListener.js +40 -0
  5. package/lib/parse/ANTLR/ASTGeneration/PostgresASTGen.js +1126 -0
  6. package/lib/parse/ANTLR/ASTGeneration/SyntaxError.js +47 -0
  7. package/lib/parse/ANTLR/ASTGeneration/index.js +32 -0
  8. package/lib/parse/ANTLR/ASTGeneration/postgres/PostgreSQLLexerBase.js +43 -0
  9. package/lib/parse/ANTLR/ASTGeneration/postgres/PostgreSQLParserBase.js +37 -0
  10. package/lib/parse/ANTLR/ASTGeneration/postgres/PostgresASTGen.js +1126 -0
  11. package/lib/parse/ANTLR/README.md +32 -0
  12. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLLexer.g4 +3044 -0
  13. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLLexer.interp +2074 -0
  14. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLLexer.js +882 -0
  15. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLLexer.tokens +1314 -0
  16. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLLexerBase.js +42 -0
  17. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParser.g4 +5506 -0
  18. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParser.interp +2182 -0
  19. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParser.js +3 -0
  20. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParser.tokens +1314 -0
  21. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParserBase.js +36 -0
  22. package/lib/parse/ANTLR/parsers/postgresql/PostgreSQLParserVisitor.js +5767 -0
  23. package/lib/parse/ANTLR/parsers/postgresql/README.md +10 -0
  24. package/lib/parse/Parser.js +9 -0
  25. package/lib/parse/dbml/parser.pegjs +2 -2
  26. package/lib/parse/dbmlParser.js +66 -103
  27. package/lib/parse/mssql/constraint_definition/index.js +3 -3
  28. package/package.json +6 -3
  29. package/types/import/index.d.ts +1 -1
  30. package/types/parse/Parser.d.ts +1 -0
@@ -0,0 +1,32 @@
1
+ # Setup guide
2
+ ## Install antlr4-tools
3
+ - https://github.com/antlr/antlr4-tools
4
+ ``` bash
5
+ pip install antlr4-tools
6
+ # Run antlr4 to check the version and help
7
+ ```
8
+ Note:
9
+ - For Mac OS:
10
+ - if `openjdk` is not installed, please run: `brew install openjdk`
11
+ - if can not found any Java runtime, run `brew info openjdk` and follow instruction to add `CPPFLAGS`
12
+ - if can not get latest version due to SSL error, please try to reinstall the latest version of python: https://www.python.org/downloads/macos/ then remove the older version folder
13
+ ## ANTLR4 Guide
14
+ - https://github.com/antlr/antlr4/blob/master/doc/javascript-target.md
15
+ ## Setup a new parser
16
+ 1. Create a new folder inside the `packages/dbml-core/src/parse/ANTLR/parsers` folder (e.g. `postgresql`)
17
+ 2. Go to https://github.com/antlr/grammars-v4/tree/master/sql and clone the `<lang>Lexer.G4` and `<lang>Parser.G4` to the newly created folder.
18
+ 3. Go to the folder:
19
+ ```
20
+ cd packages/dbml-core/src/parse/ANTLR/parsers/postgresql
21
+ ```
22
+ 4. Run these commands:
23
+ ``` bash
24
+ antlr4 -Dlanguage=JavaScript -no-listener -visitor <path-to-lexer>
25
+ antlr4 -Dlanguage=JavaScript -no-listener -visitor <path-to-parser>
26
+ ```
27
+ 5. Write the visitor to generate the AST
28
+
29
+
30
+ # Useful resources
31
+ - https://www.antlr.org/api/Java/org/antlr/v4/runtime/RuleContext.html
32
+ - https://github.com/antlr/antlr4-tools