Skip to content

Commit 8b37b18

Browse files
author
Psilo
committed
add README.md for antlr
1 parent a4d9b23 commit 8b37b18

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

antlr4/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# ANTLR 4 Grammar For RQL-Parsing
2+
3+
In order to help write more concise and compact code when defining REST services, we use our own RQL-like parser to generate the queries for endpoints (using interceptors).
4+
5+
## Development Setup
6+
7+
You'll need VS Code to efficiently edit, compile and test the ANTLR Lexer and Parser.
8+
9+
There is a `.vscode` directory in the `antlr4` folder containing the proper settings for VS Code.
10+
The `settings.json` contains settings for the ANTLR-plugin ([ANTLR4 grammar syntax support](https://marketplace.visualstudio.com/items?itemName=mike-lischke.vscode-antlr4)) which we use.
11+
The `launch.json` contains a debug-launch setting ready to be opened with `VS Code -> launch/debug -> open file`. Both contains variables you'll probably want to change:
12+
13+
### settings.json
14+
15+
`outputDir` is the directory (absolute) you want the parser-generator to copy the java-files into.
16+
17+
`package` is the Java fully-qualified-package-name the files it generates should bear.
18+
19+
### launch.json
20+
21+
`input` the filename of the file that is used as input-file when debugging.
22+
23+
`grammar` the grammar-file to start when hitting the debug-key.
24+
25+
`startRule` the main-rule (root) of your grammar.
26+
27+
### Usage
28+
29+
Start up VS Code and open the folder.
30+
31+
You may edit the grammar.
32+
33+
When pressing `F5` a new tab should pop up with the title `Parse Tree: Rql.g4` showing the resulting parse-tree after parsing your grammar (see settings in `launch.json`).
34+
35+
You may also go to your grammar file, right click and select either:
36+
37+
- Show Railroad Diagram for Rule
38+
- Show Railroad Diagram for all Rules
39+
- Show ATN Graph for Rule
40+
- Show Grammar Call Graph
41+
42+
Which will open in a new tab and are, depending on which point you chose, depending on the rule your cursor currently is located in.
43+
44+
After pressing `F5` your grammar is generated and the files are copied.
45+
46+
Change to your Eclipse and refresh the folder the classes are located in, for Eclipse to detect and process the changes.
47+
48+
You may use the visitor now and run some tests.

0 commit comments

Comments
 (0)