12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- # RAKU is a simple, fun to use and to embed scripting language.
- # The syntax resembles TCL somewhat but it's semantics are somewhat lisp like.
- STATEMENTS ← ((STATEMENT COMMENT? / COMMENT) EOS)+
- ~COMMENT ← "#---" (!("---#").)* "---#" / "#" (!([\r\n]+).)*
- STATEMENT ← TERM ( OPERATOR TERM )*
- TERM ← CALL / VALUE / BLOCK / PBLOCK / BBLOCK
- CALL ← VALUE ARGUMENTS
- BLOCK ← "{" EOS? STATEMENTS? "}"
- BBLOCK ← "[" EOS? STATEMENTS? "]"
- PBLOCK ← "(" EOS? STATEMENT EOS? ")"
- ARGUMENTS ← (BLOCK / PBLOCK / BBLOCK / VALUE)+
- OPERATOR ← < [-+/*] / "<<" / ">>" / "<-" / "->" / "<=>" / "<=" / ">=" / "<" / ">" /
- ".." / "." /
- "&&"/ "&" / "||" / "|" / "^^" / "^" / "==" / "=" >
- VALUE ← WORD / SYMBOL / STRING / NUMBER
- STRING ← SYMBOL / ESCSTR / RAWSTR
- # Raw string macro
- RAWSM(O,C) ← O < (!(C).)* > C
- # Escaped string macro.
- ESCSM(O,C) ← O < (!(C)STRCHAR)* > C
- SYMBOL ← < ":" WORD >
- ESCSTR ← ESCSM("`", "`") / ESCSM('"', '"')
- RAWSTR ← RAWSM("'", "'") / RAWSM('«', '»') / RAWSM('‹', '›') / RAWSM('“', '”')
- STRESC1 ← "\\" [nrtfv\'\\"\[\]\\]
- STRESC2 ← "\\" [0-3] [0-7] [0-7]
- STRESC3 ← "\\" [0-7] [0-7]*
- STRESC4 ← "\\x" [0-9a-fA-F] [0-9a-fA-F]?
- STRESC5 ← "\\u" [0-9a-fA-F]+
- STRNOESC ← (!('\\\\').)
- STRCHAR ← STRESC1 / STRESC2 / STRESC3 / STRESC4 / STRESC5 / STRNOESC
- NUMBER ← DECIMAL / INTEGER
- DECIMAL ← < [-+]?[0-9]+[.][0-9]+ >
- INTEGER ← < [-+]?[0-9]+ >
- ~EOS ← ([ \t]*[\r\n;]+[ \t]*)+
- WORD ← < [_a-zA-Z][-_a-zA-Z0-9]* >
- WHITESPACE ← < [ \t]* >
- %whitespace ← [ \t]*
- %word ← [a-zA-Z][-+/*a-zA-Z0-9]*
- ---
- # Expression parsing option
- %expr = STATEMENT # Rule to apply 'precedence climbing method' to
- %binop = L =
- %binop = L <- ->
- %binop = L + - | ^
- %binop = L * / & << >>
- %binop = L && || ^^
- %binop = L == <=> <= >= < >
- %binop = L . ..
-
|