Code Snippets ANTLR

Short texts ANTLR 🧑‍💻 Code snippets ANTLR ✍️ Reading lists ANTLR 👀

todo.g4

grammar todo; elements : (element|emptyLine)* EOF ; element : ‘*’ ( ‘ ‘ | ‘\t’ )* CONTENT NL+ ; emptyLine : NL ; NL : ‘\r’ | ‘\n’ ; CONTENT : [a-zA-Z0-9_][a-zA-Z0-9_ \t]* ;

grammar Calculator; //lexer ruler VALUE:[0-9]+; WS:[/n/t]->skip; OPR:[+|-|*|/]+; ID:[a-z]+; //parser rules cal:expr OPR expr EOF; expr:VALUE;