Skip to content

Instantly share code, notes, and snippets.

@drojf
Created October 27, 2016 14:45
Show Gist options
  • Save drojf/2701989d94df84e1fde6f8bb85b2742d to your computer and use it in GitHub Desktop.
Save drojf/2701989d94df84e1fde6f8bb85b2742d to your computer and use it in GitHub Desktop.
grammar template;
start: in_line out_line code_group (symbol code_group)*;
in_line: IN name_type* NEWLINE;
out_line: OUT name_type* NEWLINE;
name_type: name COLON type;
name: TEXT;
type: TEXT;
code_group: code*?; //lazy match
code: TEXT | ANY_CHAR | NEWLINE | IN | OUT | CLOSE_BRACKET | OPEN_BRACKET | COLON;
//symbols eg %{hello}
symbol: OPEN_BRACKET symbol_name CLOSE_BRACKET;
symbol_name: TEXT;
//only basic parts of language here (which are always true)
OPEN_BRACKET: '%{';
CLOSE_BRACKET: '}';
IN: 'in';
OUT: 'out';
COLON: ':';
TEXT: [A-Za-z]+;
WS : [ \t]+ -> skip ; // skip spaces, tabs, newlines
NEWLINE: '\r' '\n' | '\n' | '\r';
ANY_CHAR: .;
/*
Example:
in low:int hight:int asdf:string
out low:int hight:int asdf:string
aeina
class a%{definitions}
{
dataout::::
%{definitions}
artien%{definitions}
{function%{definitions}2}
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment