-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
12 changed files
with
1,552 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.vscode | ||
.DS_Store | ||
.antlr | ||
__pycache__ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
|
||
grammar JSONMLGrammar; | ||
|
||
jsonml | ||
: hashmap | ||
| array | ||
; | ||
|
||
hashmap | ||
: '{' pair (',' pair)* '}' | ||
| '{' '}' | ||
; | ||
|
||
pair | ||
: STRING ':' value | ||
; | ||
|
||
array | ||
: '[' value (',' value)* ']' | ||
| '[' ']' | ||
; | ||
|
||
value | ||
: STRING | ||
| NUMBER | ||
| hashmap | ||
| array | ||
| 'true' | ||
| 'false' | ||
| 'null' | ||
; | ||
|
||
|
||
STRING | ||
: '"' (ESC | ~ ["\\])* '"' | ||
; | ||
fragment ESC | ||
: '\\' (["\\/bfnrt] | UNICODE) | ||
; | ||
fragment UNICODE | ||
: 'u' HEX HEX HEX HEX | ||
; | ||
fragment HEX | ||
: [0-9a-fA-F] | ||
; | ||
NUMBER | ||
: '-'? INT '.' [0-9] + EXP? | '-'? INT EXP | '-'? INT | ||
; | ||
fragment INT | ||
: '0' | [1-9] [0-9]* | ||
; | ||
// no leading zeros | ||
fragment EXP | ||
: [Ee] [+\-]? INT | ||
; | ||
// \- since - means "range" inside [...] | ||
WS | ||
: [ \t\n\r] + -> skip | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# ANTLR for file format check and parsing | ||
PROJECTLIB_PATH=$(shell pwd) | ||
ANTLR_JAR=${PROJECTLIB_PATH}/antlr-4.7.1-complete.jar | ||
export CLASSPATH=.:${ANTLR_JAR} | ||
ANTLR4=java -Xmx500M -cp "${ANTLR_JAR}:${CLASSPATH}" org.antlr.v4.Tool | ||
GRUN=java org.antlr.v4.runtime.misc.TestRig | ||
WORKDIR=./antlr_jsonml | ||
|
||
test: | ||
#rm -r ${WORKDIR} | ||
mkdir -p ${WORKDIR} | ||
cp JSONMLGrammar.g4 ${WORKDIR}/JSONMLGrammar.g4 | ||
cd ${WORKDIR}; ${ANTLR4} -Dlanguage=Python3 JSONMLGrammar.g4 | ||
cd ${WORKDIR}; ${GRUN} JSONMLGrammar jsonml -tokens |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from .bricks import BRICKS, Brick, ANALOG_CONTEXT | ||
from .renderer import Renderer, SvgRenderer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.