Skip to content

Commit

Permalink
language tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
codekansas committed Sep 24, 2024
1 parent 3e8bb03 commit 4fed18c
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions klang/src/klang.pest
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ statement = {
expression_stmt |
for_loop |
while_loop |
if_statement
if_statement |
empty_stmt
)
}

empty_stmt = { EOL }

assignment_stmt = { identifier ~ assign_op ~ expression ~ EOL }
assign_op = { "=" | "+=" | "-=" | "*=" | "/=" }

Expand All @@ -30,30 +33,20 @@ while_loop = { "while" ~ expression ~ block }
if_statement = { "if" ~ "(" ~ expression ~ ")" ~ block }

expression_stmt = { expression ~ EOL }

expression = { conditional }

conditional = { logical_or ~ ( "?" ~ expression ~ ":" ~ expression )? }

logical_or = { logical_and ~ ( "||" ~ logical_and )* }

logical_and = { equality ~ ( "&&" ~ equality )* }

equality = { comparison ~ ( ( "==" | "!=" ) ~ comparison )* }

comparison = { additive ~ ( ( "<" | ">" | "<=" | ">=" ) ~ additive )* }

additive = { multiplicative ~ ( ( "+" | "-" ) ~ multiplicative )* }

multiplicative = { unary ~ ( ( "*" | "/" ) ~ unary )* }

unary = { ( "!" | "-" | "*" )* ~ primary }

primary = {
function_call |
literal |
identifier |
tuple
identifier
}

tuple = { "(" ~ expression_list ~ ")" }
Expand Down

0 comments on commit 4fed18c

Please sign in to comment.