Skip to content

Instantly share code, notes, and snippets.

@thosakwe
Created November 2, 2016 01:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thosakwe/d55f5c8604a245f37bc9074183a057e0 to your computer and use it in GitHub Desktop.
Save thosakwe/d55f5c8604a245f37bc9074183a057e0 to your computer and use it in GitHub Desktop.
Pug (nee Jade) with ANTLR
html
body
h1 Hello
p Foo
html { body { h1 Hello {} p Foo {} } }
grammar Grammar;
WS: [ \n\r\t] -> skip;
ID: [A-Za-z_] [A-Za-z0-9_]*;
compilationUnit: block*;
block: name=ID '{' (stmt ';'*)* '}';
stmt:
block #BlockStmt
;
  1. Preprocessor
  • Count whitespace at start of each line
  • Transform into {} and ; based blocks
  1. Pass to ANTLR grammar
  2. Profit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment