describe syntax structure

This commit is contained in:
Daniel Bulant 2025-04-02 23:04:38 +02:00
parent f43b564cf6
commit 6847c92997
No known key found for this signature in database
2 changed files with 35 additions and 0 deletions

View file

@ -60,6 +60,9 @@ let literal = "$var"
# or perhaps ` ?
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
# perhaps (( x )) could be used for math expressions?
# basically just alias to (calc x)

32
syntax.deg Normal file
View 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?