Skip to content
/ risa Public

Embeddable and modular scripting language.

License

Notifications You must be signed in to change notification settings

exom-dev/risa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About CMake 3.15C 99

Risa is an embeddable and modular scripting language.

This implementation is extremely early, work-in-progress and, therefore, not yet ready for an alpha release. Many parts of the code are temporary, and WILL be changed.

Extended BNF (EBNF) notation

This is the EBNF notation for Risa's grammar.

script ::= ( space declaration space )* EOF ;

declaration ::= fnDecl
              | varDecl
              | stmt ;

fnDecl  ::= "function" space fn ;
varDecl ::= "var" space IDENTIFIER ( space "=" expr)? ";" ;

fn     ::= IDENTIFIER space "(" space params? space ")" ( block | "=>" expr );
params ::= IDENTIFIER ( "," space IDENTIFIER )* ;

stmt ::= exprStmt
       | ifStmt
       | whileStmt
       | forStmt
       | returnStmt
       | continueStmt
       | breakStmt
       | block ;

exprStmt     ::= expr ";" space ;
ifStmt       ::= "if" space "(" expr ")" space stmt space ( space "else" space stmt space )? ;
whileStmt    ::= "while" space "(" expr ")" space stmt ;
forStmt      ::= "for" "(" ( varDec | exprStmt | ";" ) expr? ";" expr? ")" space stmt ;
returnStmt   ::= space "return" expr? ";" ;
continueStmt ::= space "continue" INTEGER? ";" ;
breakStmt    ::= space "break" INTEGER? ";" ;
block        ::= space "{" declaration* "}" ;

expr ::= space comma space ;

comma ::= assignment space "," space assignment ;

assignment ::= ( call space "." space )? IDENTIFIER space "=" space assignment
             | ternary ;

ternary ::= or space "?" expr ":" expr ;

or  ::= and ( "||" and)* ;
and ::= bitwiseOr ( "&&" bitwiseOr )* ;

bitwiseOr  ::= bitwiseXor ( "|" bitwiseXor )* ;
bitwiseXor ::= bitwiseAnd ( "^" bitwiseAnd )* ;
bitwiseAnd ::= equality ( "&" equality )* ;

equality       ::= comparison ( ( "==" | "!=" ) comparison )* ;
comparison     ::= shift ( ( "<" | "<=" | ">" | ">=" ) shift )* ;
shift          ::= addition ( ( "<<" | ">>" ) addition )* ;
addition       ::= multiplication ( ( "+" | "-" ) multiplication )* ;
multiplication ::= unary ( ( "*" | "/" | "%" ) unary )* ;

unary ::= space ( ( "!" | "-" | "~" ) unary | call ) space ;
call  ::= primary ( "(" args? ")" | "[" expr "]" | "." IDENTIFIER )* ;
args  ::= expr ( "," expr )* ;

primary ::= "null"
          | "true"
          | "false"
          | NUMBER
          | STRING
          | IDENTIFIER
          | "(" expr ")" 
          | lambda
          | array ;

lambda ::= "(" args? ")" space "=>" ( expr | block ) ;

array ::= "[" args? "]" ;

space ::= ""
        | " "
        | "\t"
        | "\r"
        | "\n"
        | comment ;

comment ::= "//" ( COMMENTCHAR )*
          | "/*" ( ANYCHAR )* "*/" ;

COMMENTCHAR ::= [#x00-#x09#x0B-#xFF] ;
ANYCHAR     ::= [#x00-#xFF] ;

NUMBER ::= BYTE
         | INTEGER
         | FLOAT ;

STRING     ::= "\"" STRCHAR "\"" ;
IDENTIFIER ::= ALPHA ( ALPHA | DIGIT )* ;

BYTE    ::= DIGIT+ "b" ;
INTEGER ::= DIGIT+ ;
FLOAT   ::= DIGIT+ "." DIGIT+ [ "f" ]
          | DIGIT+ "f" ;

STRCHAR ::= [#x00-#x09#x0B-#x21#x23-#xFF] | "\\\"" ;

ALPHA ::= [a-zA-Z] | "_" ;
DIGIT ::= [0-9] ;

License License: MIT

This project was created by The Exom Developers.

The Risa project is licensed under the MIT license.

References

About

Embeddable and modular scripting language.

Resources

License

Stars

Watchers

Forks

Packages

No packages published