Skip to content

Latest commit

 

History

History
59 lines (40 loc) · 1.64 KB

Grammer.md

File metadata and controls

59 lines (40 loc) · 1.64 KB
programstatement* EOF ;


statementexprStmt
               | ifStmt
               | printStmt
               | returnStmt
               | whileStmt
               | block

returnStmt     → "return" expression? ";"

whileStmt      → "the one who knocks" "(" expression ")" statement ";"

ifStmt         → "jesse if" "(" expression ")" statement 
                 ( "else"statement )?

block"{" declaration* "}" 

declarationfunDecl
               | varDecl
               | statement 

funDecl"better call " function;
functionIDENTIFIER "(" parameters? ")" block
parametersIDENTIFIER ( "," IDENTIFIER )* ";"

varDecl"cook" IDENTIFIER ( "=" expression )? ";" 



exprStmtexpression ";" 
cookStmt"cook" expression ";"


expressionassignment ";"
assignmentIDENTIFIER "=" assignment";"
               | logic_or ";"

logic_orlogic_and ( "or" logic_and )* ;
logic_andternary ( "and" ternary )* ;

ternaryequality
               | equality "?" equality ":" equality ";"

equality       → comparison ( ( "!=" | "==" ) comparison )* ";"
comparison     → term ( ( ">" | ">=" | "<" | "<=" ) term )* ";"
term           → factor ( ( "-" | "+" ) factor )* ";"
factor         → unary ( ( "/" | "*" ) unary )* ";"
unary          → ( "!" | "-" ) unary | call ";"

call           → primary ( "(" arguments? ")" )* ";"
arguments      → expression ( "," expression )* ;

primary        → METH | STRING | "cartel" | "dea" | "i am the danger"
               | "(" expression ")" 
               | IDENTIFIER;