Grammar GCLangParser
ANTLR-generated HTML file from edu/toronto/cs/gclang/parser/gclang.g

Terence Parr, MageLang Institute
ANTLR Version 2.7.2; 1989-1999


Definition of parser GCLangParser, which is a subclass of LLkParser.


expr
	:	implExpr 
	|	setExpr 
	;


implExpr
	:	iffExpr ( IMPLIES iffExpr )* 
	;


setExpr
	:	LBRACE setElement ( COMMA setElement )* RBRACE 
	;


iffExpr
	:	orExpr ( IFF orExpr )* 
	;


orExpr
	:	andExpr ( (	OR 
			|	XOR 
			) 
			andExpr )* 
	;


andExpr
	:	negExpr ( AND negExpr )* 
	;


negExpr
	:	(	NEG 
		|	
		) 
		comparisonExpr 
	;


comparisonExpr
	:	modExpr ( (	EQ 
			|	NEQ 
			|	LT 
			|	GT 
			|	LEQ 
			|	GEQ 
			) 
			modExpr )* 
	;


modExpr
	:	sumExpr ( MOD sumExpr )* 
	;


sumExpr
	:	multExpr ( (	PLUS 
			|	MINUS 
			) 
			multExpr )* 
	;


multExpr
	:	basicExpr ( (	MULT 
			|	DIV 
			) 
			basicExpr )* 
	;


basicExpr
	:	VARNAME 
	|	number 
	|	boolConstant 
	|	LPAREN expr RPAREN 
	;


number
	:	NUMBER 
	;


boolConstant
	:	TRUE 
	|	FALSE 
	;


protected atomValued
	:	VARNAME 
	;


protected numberValued
	:	NUMBER 
	;


atom
	:	VARNAME 
	;


setElement
	:	textOrNumber 
	;


protected textOrNumber
	:	atom 
	|	number 
	;


varBlock
	:	VAR ( varDecl )+ 
	;


varDecl
	:	atomValued COL type SEMI 
	;


type
	:	BOOLEAN 
	|	textSet 
	;


textSet
	:	LBRACE textOrNumberValued ( COMMA textOrNumberValued )* RBRACE 
	;


protected textOrNumberValued
	:	atomValued 
	|	numberValued 
	;


command
	:	sequenceCommand 
	;


sequenceCommand
	:	choiceCommand ( SEMI choiceCommand )* 
	;


choiceCommand
	:	atomicCommand ( CHOICE atomicCommand )* 
	;


atomicCommand
	:	assign 
	|	skip 
	|	ite 
	|	LPAREN command RPAREN 
	;


assign
	:	atom ASSIGNOP expr 
	;


skip
	:	SKIP 
	;


ite
	:	IF LPAREN expr RPAREN 
		(	THEN 
		|	
		) 
		iteBody 
	;


iteBody
	:	command ELSE command FI 
	;


protected guard
	:	expr 
	;


guardedCommand
	:	guard COL command 
	;


rulesBlock
	:	RULES ( guardedCommand )+ 
	;


initBlock
	:	INIT expr 
		(	SEMI 
		|	
		) 
	;


start
	:	NAME atom varBlock initBlock rulesBlock EOF 
	;