Outils pour utilisateurs

Outils du site


kmelia:keywords

Alphabet and keywords

protected DIGIT : '0'..'9';
protected UNDER : '_';
protected LETTER : 'a'..'z' | 'A'..'Z';
protected BIDIRPIPE : "<|>";
 
NUMBER : DIGIT (DIGIT)*;
WORD : LETTER (DIGIT | LETTER | UNDER)* ;
 
protected GOTO : "GOTO" ;
// ports
SELF : "_SELF";
CALLER :"_CALLER";
 
LINKTYPE : "r-r"|"r-p"|"p-p"|"p-r";
PORT : UNDER (WORD | SELF | CALLER);
 
//PRIMITIVE TYPES
protected INTEGER_TYPE :"INT";
protected BOOL_TYPE:"BOOL";
protected STRING_TYPE:"STRING";
protected INTEGER : NUMBER;
 
LT : '<';
GT : '>';
EQ : '=';
DIFF : "<>";
LE : "<=";
GE : ">=";
 
PIPE : "|";
ARROW_START : "--";
ARROW_END : "-->" ;
COMMA : ',';
SEMICOLON : ';';
BLOCK_START : '{';
BLOCK_END : '}';
PAR_START : '(';
PAR_END : ')';
BRACKET_START : '[';
BRACKET_END : ']';
DB_EXCLAM_MARK : "!!";
DB_QUESTION_MARK : "??";
QUESTION_MARK : '?';
EXCLAM_MARK : '!';
AFFECTE : ":=";
COLON : ':';
QUOT_MARK : '\"';
PERIOD : '.';
protected DOTDOT : PERIOD PERIOD;

Keywords and Operators (contd.)

PLUS : '+';
MINUS : '-';
MULT : '*';
DIV : '/';
//OP_COMP : '=' | "<" | '>' |"<>" | "<=" | ">="; 
protected BOOL_OPERATORS : LAND|LOR|OP_NOT|LNOT|BNOT|TRUE|FALSE;
protected OP_COMP : LT | GT | EQ | DIFF | LE | GE;
protected OP_CALC :PLUS|MINUS|MULT|DIV|INCR|ARROW_START;
//OPERATORS : BOOL_OPERATORS|OP_COMP|OP_CALC;
LAND : "&&";
LOR : "||" ;
protected OP_NOT : "not"; 
LNOT			:	'!'	;
BNOT			:	'~'	;
TRUE : "true";
FALSE : "false";
FOR_ALL : "\\forall";
EXISTS : "\\exists";
INCR : "++";

Identifiers and separators

WS    :
    (' ' 
    | '\t' 
    | '\r' '\n' { newline(); } 
    | '\n'      { newline(); }
    )     { $setType(Token.SKIP); } ;
SPECIAL_CHARS : '@'|'%'|'\\'|'\''|'^'|'&'|'|';
 
// Single-line comments
protected AT_SL_COMMENT 
        :("@")
			(~('\n'|'\r'))* ('\n'|'\r'('\n')?)
	;
IDENT
	options {testLiterals=true;}
	:	('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')* ;
// character literals
protected CHAR_LITERAL
	:	'\'' ( ESC | ~('\''|'\n'|'\r'|'\\') ) '\''
	;
// string literals
STRING_LITERAL
	:	'"' (ESC|~('"'|'\\'|'\n'|'\r'))* '"'
	;
// escape sequence -- note that this is protected; it can only be called
// from another lexer rule -- it will not ever directly return a token to
// the parser
protected ESC
	:	'\\'
		(	'n'
		|	'r'
		|	't'
		|	'b'
		|	'f'
		|	'"'
		|	'\''
		|	'\\'
		)
	;
IMP_ML_COMMENT
	:	"/*" 
	(~('*'))* "*/" ;

Identifiers and separators (contd.)

SL_COMMENT
		:	("//" or| "#")
			(~('\n'|'\r'))* ('\n'|'\r'('\n')?)
			{$setType(Token.SKIP); newline();}
		;
NEWLINE   :  ( "\r\n" // DOS
               | '\r'   // MAC
               | '\n'   // Unix
             )
             { newline(); 
               $setType(Token.SKIP);
             }
          ;
kmelia/keywords.txt · Dernière modification: 2018/04/03 16:59 (modification externe)