[antlr-interest] hard to resolve non-determinism (the entire file)

Anthony Brenelière abreneliere at telys.com
Wed Feb 5 10:31:05 PST 2003


options {
	language="Cpp";
}

class CIAOParser extends Parser;

options {
	k = 3;
	buildAST = true;
	exportVocab = CIAO;
}

// Root the the CIAO grammar

ciaoDocument
	{ antlr::DEBUG_PARSER = 1; }
	:	(statements)+
;

statements
	:	"CONSTRAINT" statement "ENDCONSTRAINT"
;

statement
	:	"USE" use 
;

// V - Declaration of uses
use
	:	entSetAttList	// use of 'entSetAttList'
;

entSetAtt
	:	( entity | (simpleAttribute)=> entity simpleAttribute |
simpleAttribute )
;

entSetAttList	// (supplier WHERE name="Telys"):client, service
	:	entSetAtt
	( COMMA entSetAtt )*
;

entity // (supplier WHERE name="Telys"):client
	:	entityComponent (COLON entity)?
;

entityComponent // (supplier WHERE name="Telys")
	:	LPAREN IDENTIFIER clause RPAREN
	|	IDENTIFIER 
;

clause
	:	"WHERE" // conditionalExpression
;
/*
attribute	// ::supplier:client.address
	:	entity simpleAttribute 
	|	simpleAttribute 
;*/

simpleAttribute	// .name
	:	DOT IDENTIFIER 
;

//----------------------------------------------------------------------
------
// The CIAO scanner
//----------------------------------------------------------------------
------
{
#include <string>
}
class CIAOLexer extends Lexer;

options {
	// testLiterals=false;
	exportVocab = CIAO;
	k=4;
	// charVocabulary='\u0003'..'\u00FF';
	charVocabulary='\3'..'\377';
	
	// without inlining some bitset tests, couldn't do unicode;
	// I need to make ANTLR generate smaller bitsets; see
	// bottom of JavaLexer.java
	// codeGenBitsetTestThreshold=20;
}

// Operators
//
QUESTION		:	'?'		;
LPAREN			:	'('		;
RPAREN			:	')'		;
LBRACK			:	'['		;
RBRACK			:	']'		;
LCURLY			:	'{'		;
RCURLY			:	'}'		;
COLON			:	':'		;
DB_COLON		:	"::"	;
COMMA			:	','		;
DOT				:	'.'		;
ASSIGN			:	":="	;
EQUAL			:	"="		;
LNOT			:	'!'		;
BNOT			:	'~'		;
NOT_EQUAL		:	"!="	;
DIV				:	'/'		;
DIV_ASSIGN		:	"/="	;
PLUS			:	'+'		;
PLUS_ASSIGN		:	"+="	;
INC				:	"++"	;
MINUS			:	'-'		;
MINUS_ASSIGN	:	"-="	;
DEC				:	"--"	;
STAR			:	'*'		;
STAR_ASSIGN		:	"*="	;
MOD				:	'%'		;
MOD_ASSIGN		:	"%="	;
SR				:	">>"	;
SR_ASSIGN		:	">>="	;
BSR				:	">>>"	;
BSR_ASSIGN		:	">>>="	;
GE				:	">="	;
GT				:	">"		;
SL				:	"<<"	;
SL_ASSIGN		:	"<<="	;
LE				:	"<="	;
LT_				:	'<'		;
BXOR			:	'^'		;
BXOR_ASSIGN		:	"^="	;
BOR				:	'|'		;
BOR_ASSIGN		:	"|="	;
LOR				:	"||"	;
BAND			:	'&'		;
BAND_ASSIGN		:	"&="	;
LAND			:	"&&"	;
SEMI			:	';'		;
LIN				:	"==>"	;
RIN				:	"<=="	;
REQU			:	"<==>"	;

// Whitespace and new lines characters are ignored
WS
	:	( ' ' | '\t' | '\f' | 
		( options { generateAmbigWarnings=false; } :
			"\r\n" | '\r' | '\n' )	{ newline(); } )+
	{ $setType(ANTLR_USE_NAMESPACE(antlr)Token::SKIP); }
;

IDENTIFIER
	// options { testLiterals=true; }
	: ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*
;

STRING
	:	'"' (~'"')* '"'
	|	'\'' (~'\'')* '\''
;
	
INTEGER
	:	('0'..'9')+
;


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list