Skip to content

Commit

Permalink
Add preliminary ANTLR 4 grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
enzet committed Aug 19, 2023
1 parent 1667ab3 commit 32a55da
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions grammar/Moire.g4
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Grammar for Moire markup language.
*
* @author Sergey Vartanov
* @since 2 September 2022
*/
grammar Moire;

document : markup EOF ;
markup : ( tag | TEXT | WHITESPACE | escapedCharacter | DELIMITER )+ ;
tag : TAG_NAME ( WHITESPACE? argument )* ;
argument : CURLY_OPEN markup CURLY_CLOSE ;
escapedCharacter : BACKSLASH (BACKSLASH | CURLY_OPEN | CURLY_CLOSE) ;

DELIMITER : '\n\n' ;
BACKSLASH : '\\' ;
CURLY_OPEN : '{' ;
CURLY_CLOSE : '}' ;
fragment IDENTIFIER : [A-Za-z0-9_]+;
TAG_NAME: BACKSLASH IDENTIFIER;
WHITESPACE : [ \t\n\r]+;
TEXT : [A-Za-z. \n\t\r]+;

0 comments on commit 32a55da

Please sign in to comment.