Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- chunk = { func_decl }
- name = { "a"..."z" | "A"..."Z" | "0"..."9" | "_" }
- string ::= """ (* tout et n'importe quoi *) """
- number ::= "0"..."9"
- block ::= name "=" expr |
- "if" expr "{" block "}" { "else if" expr "{" block "}" } [ "else" "{" block "}" ] |
- "loop" [ number ] "{" block "}" |
- "while" expr "{" block "}" |
- "for" name "=" number ( "to" | "till" ) number [ "by" number ] "{" block "}" |
- "for" name "in" iterable "{" block "}" |
- "return" expr |
- "break" |
- "continue"
- expr ::= value |
- func_call |
- expr op_binary expr |
- op_binary expr
- value ::= "nil" |
- "false" |
- "true" |
- number |
- string |
- iterable
- iterable ::= "[" { expr "," } "]" |
- "{" { string "=>" expr "," } "}"
- func_decl ::= func_name "(" par_list ")" "{" block "}"
- func_name ::= name { "." name }
- par_list ::= par_arg { "," par_arg }
- par_arg ::= [ "&" ] name
- func_call ::= func_name "(" { expr } ")"
- op_binary ::= "+" | "-" | "*" | "/" | "^" | "%" |
- "<" | "<=" | ">" | ">=" | "==" | "<>" |
- "and" | "or"
- op_unary ::= "-" | "not"
- -----
- Exemple d'utilisation :
- main() {
- if 1 + 1 == 3 {
- Console.log("1 + 1 = 3")
- } else if 1 + 1 == 2 {
- Console.log("1 + 1 = 2")
- } else {
- Console.log("1 + 1 = ?")
- }
- loop 6 { }
- while true { break }
- for i = 0 to 50 by 2 { }
- for i in [ 0, 50, 60 ] { }
- return 0
- }
- -----
- Pas entièrement la même syntaxe mais peut servir de référence :
- http://pastie.org/pastes/6574368
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement