Artifact
f598da11baf09ad875b52556b45bf4662917eed5:
Attachment "EmuQL.peg" to
ticket [3064747fff]
added by
dargosch
2010-09-12 19:38:00.
PEG EmuQL (expression)
expression <- unionexpression / dominanceexpressionR / dominanceexpression / sequentialexpressionL / sequentialexpressionR /sequenceexpression / functionexpression /labeltypeexpression ;
subexpression <- functionexpression / labeltypeexpression / ('[' expression ']') ;
labeltypeexpression <- (WHITESPACE labeltype WHITESPACE stringcompareoperator WHITESPACE labelsequence WHITESPACE) ;
#/ (WHITESPACE labeltype WHITESPACE);
#Dominance expressions
#Default is left part returned, so this is the default match
dominanceexpression <- WHITESPACE (TARGETMARK)* WHITESPACE subexpression WHITESPACE dominanceoperator WHITESPACE subexpression WHITESPACE ;
dominanceexpressionR <- WHITESPACE subexpression WHITESPACE dominanceoperator WHITESPACE TARGETMARK WHITESPACE subexpression WHITESPACE ;
#Sequences
#The whole sequence
sequenceexpression <- WHITESPACE subexpression WHITESPACE sequenceoperator WHITESPACE subexpression WHITESPACE ;
#Return part marked
sequentialexpressionL <- WHITESPACE TARGETMARK WHITESPACE subexpression WHITESPACE sequenceoperator WHITESPACE subexpression WHITESPACE ;
sequentialexpressionR <- WHITESPACE subexpression WHITESPACE sequenceoperator WHITESPACE TARGETMARK WHITESPACE subexpression WHITESPACE ;
#Joined expressions
unionexpression <- subexpression WHITESPACE '&' WHITESPACE subexpression WHITESPACE (ANDOPERATOR WHITESPACE subexpression)* ;
#Function calls
functionexpression <- WHITESPACE function '(' WHITESPACE labeltype WHITESPACE ',' WHITESPACE labeltype WHITESPACE ')' WHITESPACE numbercompareoperator WHITESPACE number WHITESPACE;
#Basic components
function <- 'Start' / 'Mid' / 'End' / 'Num' / 'Position';
labeltype <- <alnum>+ ;
number <- (<digit>/<ddigit>)+;
labelsequence <- label (OROPERATOR label)*;
label <- (WHITESPACE STRINGMARK STRINGMARK WHITESPACE) / (WHITESPACE STRINGMARK (!(STRINGMARK (OROPERATOR/EOS)) unicodestring)* STRINGMARK WHITESPACE) / (WHITESPACE asciistring WHITESPACE) ;
unicodestring <- "\\" [nrt'"\[\]\\] / "\\" [0-2][0-7][0-7] / "\\" [0-7][0-7]? / "\\" 'u' HexDigit (HexDigit (HexDigit HexDigit?)?)? / !"\\" . ;
asciistring <- <alnum>+;
sequenceoperator <- '->' / '-->' / namedsequenceoperator ;
namedsequenceoperator <- '-' labeltype '->';
stringcompareoperator <- '=' / '==' / '!=' / '~' / '~~' / '!~' / '!~~';
numbercompareoperator <- '=' / '==' / '!=' / '<' / '>' / '<=' / '>=';
dominanceoperator <- '^' / '~^';
void: OROPERATOR <- '|' ;
void: ANDOPERATOR <- '&' ;
void: WHITESPACE <- (" " / "\t" / "\r" / "\n" )* ;
void: FWHITESPACE <- (" " / "\t" / "\r" / "\n" )+;
void: TARGETMARK <- '#';
void: STRINGMARK <- "'" ;
void: EOL <- "\n\r" / "\n" / "\r" ;
void: EOS <- !unicodestring;
END ;