mirror of
https://github.com/danbulant/rush
synced 2026-07-08 12:40:42 +00:00
describe syntax structure
This commit is contained in:
parent
f43b564cf6
commit
6847c92997
2 changed files with 35 additions and 0 deletions
|
|
@ -60,6 +60,9 @@ let literal = "$var"
|
||||||
# or perhaps ` ?
|
# or perhaps ` ?
|
||||||
let formatted = f"$var"
|
let formatted = f"$var"
|
||||||
|
|
||||||
|
# these are builtin commands rather than syntax structures (unlike let/while etc)
|
||||||
|
# they simply accept arguments and work with them as with any other
|
||||||
|
# builtin commands accept structures rather than strings
|
||||||
test 1 = 1
|
test 1 = 1
|
||||||
# perhaps (( x )) could be used for math expressions?
|
# perhaps (( x )) could be used for math expressions?
|
||||||
# basically just alias to (calc x)
|
# basically just alias to (calc x)
|
||||||
|
|
|
||||||
32
syntax.deg
Normal file
32
syntax.deg
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
|
||||||
|
# also includes quotes and format strings
|
||||||
|
STRING = !SPECIALS
|
||||||
|
|
||||||
|
NUMBER = 1-9
|
||||||
|
ALFA = a-zA-Z
|
||||||
|
EOL = \n
|
||||||
|
IDENT = ALFA (ALFA | NUMBER)*
|
||||||
|
|
||||||
|
VARIABLE = $IDENT
|
||||||
|
INDEX = VALUE ( "[" VALUE "]" ) +
|
||||||
|
|
||||||
|
PRIMITIVE_VALUES = NUMBER | STRING | VARIABLE | INDEX
|
||||||
|
|
||||||
|
# group and object destructors/bindings will be here
|
||||||
|
BINDABLE = PRIMITIVE_VALUES
|
||||||
|
|
||||||
|
VALUE = PRIMITIVE_VALUES | GROUP
|
||||||
|
|
||||||
|
GROUP = "(" COMMAND ")"
|
||||||
|
|
||||||
|
COMMAND = ( VALUE WHITESPACE ) +
|
||||||
|
|
||||||
|
LET = let BINDABLE = VALUE
|
||||||
|
|
||||||
|
FOR = for BINDABLE in VALUE { STATEMENTS }
|
||||||
|
IF = if VALUE { STATEMENTS } ( else if VALUE { STATEMENTS } ) * ( else { STATEMENTS } )?
|
||||||
|
WHILE = while VALUE { STATEMENTS } ( else { STATEMENTS } )?
|
||||||
|
LOOP = loop { STATEMENTS }
|
||||||
|
|
||||||
|
STATEMENT = COMMAND | LET | FOR | IF | WHILE | LOOP
|
||||||
|
STATEMENTS = ( STATEMENT (; | EOL) )* STATEMENT?
|
||||||
Loading…
Reference in a new issue