Skip to content

Instantly share code, notes, and snippets.

@hugobarauna
Created November 19, 2009 03:32
Show Gist options
  • Save hugobarauna/238528 to your computer and use it in GitHub Desktop.
Save hugobarauna/238528 to your computer and use it in GitHub Desktop.
Program
program = { decl }
Declarações
decl = type var_list | type id "=" ( id | num | expr ) | func_decl | array | struct.
var_list = id { "," id } "\n".
array = type id "[" num "]" | type id "[" num "]" "=" "{" cte {, cte} "}".
struct = "struct" id "{" struct_var_list "}"
struct_var_list = type id "\n" { type id "\n" }.
type = "int" | "char" | "float" | "bool" | "void".
terminator = "\n". ver ainda se usar o terminator explicitamente
Expressões
stmt = "if" "(" cond_expr ")" "do" stmt "end"
| "if" "(" cond_expr ")" "do" stmt "else" stmt "end"
| "while" "(" cond_expr ")" "do" stmt "end"
| "return" [ expr ]
| assignment.
assignment = expr | id "=" expr.
expr = term { ("+" | "-") term }.
term = factor { ("*" | "/" ) factor }.
factor = id | cte.
Funcões
func_decl = type ( operation | id ) "(" params_list ") "do" stmt "end".
params_list = param { "," param }.
param = type id.
operation = id ( "?" | "!" ). #nome de função terminando em ? ou !
Entrada e saída
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment