Skip to content

Instantly share code, notes, and snippets.

@prakhar-shukla-in
Created June 25, 2020 14:15
Show Gist options
  • Save prakhar-shukla-in/fc1a93bfd736ae5c32487292c987afab to your computer and use it in GitHub Desktop.
Save prakhar-shukla-in/fc1a93bfd736ae5c32487292c987afab to your computer and use it in GitHub Desktop.
//parser
grammar drunkPeople;
root
: statement* EOF
;
statement
: I DRANK something
;
something
: BEER | WINE | VODKA | RUM
//lexer
fragment A : [aA] ;
fragment B : [bB] ;
fragment C : [cC] ;
fragment D : [dD] ;
fragment E : [eE] ;
fragment F : [fF] ;
fragment G : [gG] ;
fragment H : [hH] ;
fragment I : [iI] ;
fragment J : [jJ] ;
fragment K : [kK] ;
fragment L : [lL] ;
fragment M : [mM] ;
fragment N : [nN] ;
fragment O : [oO] ;
fragment P : [pP] ;
fragment Q : [qQ] ;
fragment R : [rR] ;
fragment S : [sS] ;
fragment T : [tT] ;
fragment U : [uU] ;
fragment V : [vV] ;
fragment W : [wW] ;
fragment X : [xX] ;
fragment Y : [yY] ;
fragment Z : [zZ] ;
BEER : B E E R;
WINE : W I N E;
VODKA : V O D K A;
RUM : R U M;
SPACE : [ \t\r\n]+ -> skip
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment