Updated grammar aggresively
This commit is contained in:
+2
-25
@@ -11,7 +11,6 @@ boolean = { "true" | "false" }
|
|||||||
string_lit = { "\"" ~ inner_str ~ "\"" }
|
string_lit = { "\"" ~ inner_str ~ "\"" }
|
||||||
inner_str = @{ (!"\"" ~ ANY)* }
|
inner_str = @{ (!"\"" ~ ANY)* }
|
||||||
|
|
||||||
// ================= PREREQUISITES =================
|
|
||||||
export = { "public" }
|
export = { "public" }
|
||||||
mutable = { "mut" }
|
mutable = { "mut" }
|
||||||
var_decl_1 = { type_expr ~ mutable? ~ identifier }
|
var_decl_1 = { type_expr ~ mutable? ~ identifier }
|
||||||
@@ -43,11 +42,9 @@ statement_list = { statement* }
|
|||||||
|
|
||||||
statement = _{
|
statement = _{
|
||||||
expr_stmt
|
expr_stmt
|
||||||
| var_decl
|
| var_decl_statement
|
||||||
| var_assign
|
|
||||||
| if_stmt
|
| if_stmt
|
||||||
| while_stmt
|
| while_stmt
|
||||||
| for_stmt
|
|
||||||
| return_stmt
|
| return_stmt
|
||||||
| break_stmt
|
| break_stmt
|
||||||
| continue_stmt
|
| continue_stmt
|
||||||
@@ -64,19 +61,7 @@ break_stmt = { "break" ~ ";" }
|
|||||||
|
|
||||||
continue_stmt = { "continue" ~ ";" }
|
continue_stmt = { "continue" ~ ";" }
|
||||||
|
|
||||||
// --- variable declarations ---
|
var_decl_statement = { var_decl_1 ~ ";" }
|
||||||
|
|
||||||
// var_decl_kind = { "let" | "const" | "var" }
|
|
||||||
|
|
||||||
var_decl = {
|
|
||||||
type_expr ~ identifier ~ ("=" ~ expr)? ~ ";"
|
|
||||||
}
|
|
||||||
|
|
||||||
var_assign = {
|
|
||||||
expr ~ "=" ~ expr ~ ";"
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- control flow ---
|
|
||||||
|
|
||||||
if_stmt = {
|
if_stmt = {
|
||||||
"if" ~ "(" ~ expr ~ ")" ~ statement ~ ("else" ~ statement)?
|
"if" ~ "(" ~ expr ~ ")" ~ statement ~ ("else" ~ statement)?
|
||||||
@@ -86,14 +71,6 @@ while_stmt = {
|
|||||||
"while" ~ "(" ~ expr ~ ")" ~ statement
|
"while" ~ "(" ~ expr ~ ")" ~ statement
|
||||||
}
|
}
|
||||||
|
|
||||||
for_stmt = {
|
|
||||||
"for" ~ "(" ~ var_decl ~ expr ~ ";" ~ var_assign_no_semicolon ~ ")" ~ statement
|
|
||||||
}
|
|
||||||
|
|
||||||
var_assign_no_semicolon = {
|
|
||||||
expr ~ "=" ~ expr
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================= EXPRESSIONS =================
|
// ================= EXPRESSIONS =================
|
||||||
type_expr = { identifier }
|
type_expr = { identifier }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user