phpdoc-parser/doc/grammars/const-expr.peg
2017-11-17 10:12:33 +01:00

50 lines
865 B
Plaintext

ConstantExpr
= ConstantFloat
/ ConstantInt
/ ConstantTrue
/ ConstantFalse
/ ConstantNull
/ ConstantString
/ ConstantArray
/ ConstantFetch
ConstantFloat
= '-'? [0-9]+ '.' [0-9]* ConstantFloatExp?
/ '-'? [0-9]* '.' [0-9]+ ConstantFloatExp?
/ '-'? [0-9]+ ConstantFloatExp
ConstantFloatExp
= [eE] '-'? [0-9]+
ConstantInt
= '-'? [0-9]+
ConstantTrue
= [tT][rR][uU][eE]
ConstantFalse
= [fF][aA][lL][sS][eE]
ConstantNull
= [nN][uU][lL][lL]
ConstantString
= '\'' ( [^'\\] / '\\' . )* '\''
/ '"' ( [^"\\] / '\\' . )* '"'
ConstantArray
= '[' ConstantArrayItems? ']'
/ 'array(' ConstantArrayItems? ')'
ConstantArrayItems
= ConstantArrayItem (',' ConstantArrayItem)* ','?
ConstantArrayItem
= ConstantExpr ('=>' ConstantExpr)?
ConstantFetch
= Identifier '::' Word
/ Identifier
# TODO: ConstantOperation, i.e. ˙2 + 3˙