mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-22 20:05:31 +00:00
Removed culebra.peg.
This commit is contained in:
parent
2b223c303f
commit
f3a65f7c61
@ -1,89 +0,0 @@
|
|||||||
|
|
||||||
PROGRAM <- _ STATEMENTS _
|
|
||||||
STATEMENTS <- (STATEMENT (_sp_ (';' / _nl_) (_ STATEMENT)?)*)?
|
|
||||||
STATEMENT <- DEBUGGER / RETURN / LEXICAL_SCOPE / EXPRESSION
|
|
||||||
|
|
||||||
DEBUGGER <- debugger
|
|
||||||
RETURN <- return (_sp_ !_nl_ EXPRESSION)?
|
|
||||||
LEXICAL_SCOPE <- BLOCK
|
|
||||||
|
|
||||||
EXPRESSION <- ASSIGNMENT / LOGICAL_OR
|
|
||||||
|
|
||||||
ASSIGNMENT <- LET _ MUTABLE _ PRIMARY (_ (ARGUMENTS / INDEX / DOT))* _ '=' _ EXPRESSION
|
|
||||||
|
|
||||||
LOGICAL_OR <- LOGICAL_AND (_ '||' _ LOGICAL_AND)*
|
|
||||||
LOGICAL_AND <- CONDITION (_ '&&' _ CONDITION)*
|
|
||||||
CONDITION <- ADDITIVE (_ CONDITION_OPERATOR _ ADDITIVE)*
|
|
||||||
ADDITIVE <- UNARY_PLUS (_ ADDITIVE_OPERATOR _ UNARY_PLUS)*
|
|
||||||
UNARY_PLUS <- UNARY_PLUS_OPERATOR? UNARY_MINUS
|
|
||||||
UNARY_MINUS <- UNARY_MINUS_OPERATOR? UNARY_NOT
|
|
||||||
UNARY_NOT <- UNARY_NOT_OPERATOR? MULTIPLICATIVE
|
|
||||||
MULTIPLICATIVE <- CALL (_ MULTIPLICATIVE_OPERATOR _ CALL)*
|
|
||||||
|
|
||||||
CALL <- PRIMARY (_ (ARGUMENTS / INDEX / DOT))*
|
|
||||||
ARGUMENTS <- '(' _ SEQUENCE _ ')'
|
|
||||||
INDEX <- '[' _ EXPRESSION _ ']'
|
|
||||||
DOT <- '.' _ IDENTIFIER
|
|
||||||
SEQUENCE <- (EXPRESSION (_ ',' _ EXPRESSION)*)?
|
|
||||||
|
|
||||||
WHILE <- while _ EXPRESSION _ BLOCK
|
|
||||||
IF <- if _ EXPRESSION _ BLOCK (_ else _ if _ EXPRESSION _ BLOCK)* (_ else _ BLOCK)?
|
|
||||||
|
|
||||||
PRIMARY <- WHILE / IF / FUNCTION / OBJECT / ARRAY / NIL / BOOLEAN / NUMBER / IDENTIFIER / STRING / INTERPOLATED_STRING / '(' _ EXPRESSION _ ')'
|
|
||||||
|
|
||||||
FUNCTION <- fn _ PARAMETERS _ BLOCK
|
|
||||||
PARAMETERS <- '(' _ (PARAMETER (_ ',' _ PARAMETER)*)? _ ')'
|
|
||||||
PARAMETER <- MUTABLE _ IDENTIFIER
|
|
||||||
|
|
||||||
BLOCK <- '{' _ STATEMENTS _ '}'
|
|
||||||
|
|
||||||
CONDITION_OPERATOR <- '==' / '!=' / '<=' / '<' / '>=' / '>'
|
|
||||||
ADDITIVE_OPERATOR <- [-+]
|
|
||||||
UNARY_PLUS_OPERATOR <- '+'
|
|
||||||
UNARY_MINUS_OPERATOR <- '-'
|
|
||||||
UNARY_NOT_OPERATOR <- '!'
|
|
||||||
MULTIPLICATIVE_OPERATOR <- [*/%]
|
|
||||||
|
|
||||||
LET <- < ('let' _wd_)? >
|
|
||||||
MUTABLE <- < ('mut' _wd_)? >
|
|
||||||
|
|
||||||
IDENTIFIER <- < IdentInitChar IdentChar* >
|
|
||||||
|
|
||||||
OBJECT <- '{' _ (OBJECT_PROPERTY (_ ',' _ OBJECT_PROPERTY)*)? _ '}'
|
|
||||||
OBJECT_PROPERTY <- MUTABLE _ IDENTIFIER _ ':' _ EXPRESSION
|
|
||||||
|
|
||||||
ARRAY <- '[' _ SEQUENCE _ ']' (_ '(' _ EXPRESSION (_ ',' _ EXPRESSION)? _ ')')?
|
|
||||||
|
|
||||||
NIL <- < 'nil' _wd_ >
|
|
||||||
BOOLEAN <- < ('true' / 'false') _wd_ >
|
|
||||||
|
|
||||||
NUMBER <- < [0-9]+ >
|
|
||||||
STRING <- ['] < (!['] .)* > [']
|
|
||||||
|
|
||||||
INTERPOLATED_STRING <- '"' ('{' _ EXPRESSION _ '}' / INTERPOLATED_CONTENT)* '"'
|
|
||||||
INTERPOLATED_CONTENT <- (!["{] .) (!["{] .)*
|
|
||||||
|
|
||||||
~debugger <- 'debugger' _wd_
|
|
||||||
~while <- 'while' _wd_
|
|
||||||
~if <- 'if' _wd_
|
|
||||||
~else <- 'else' _wd_
|
|
||||||
~fn <- 'fn' _wd_
|
|
||||||
~return <- 'return' _wd_
|
|
||||||
|
|
||||||
~_ <- (WhiteSpace / End)*
|
|
||||||
~_sp_ <- SpaceChar*
|
|
||||||
~_nl_ <- LineComment? End
|
|
||||||
~_wd_ <- !IdentInitChar
|
|
||||||
|
|
||||||
WhiteSpace <- SpaceChar / Comment
|
|
||||||
End <- EndOfLine / EndOfFile
|
|
||||||
Comment <- BlockComment / LineComment
|
|
||||||
|
|
||||||
SpaceChar <- ' ' / '\t'
|
|
||||||
EndOfLine <- '\r\n' / '\n' / '\r'
|
|
||||||
EndOfFile <- !.
|
|
||||||
IdentInitChar <- [a-zA-Z_]
|
|
||||||
IdentChar <- [a-zA-Z0-9_]
|
|
||||||
BlockComment <- '/*' (!'*/' .)* '*/'
|
|
||||||
LineComment <- ('#' / '//') (!End .)* &End
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user