summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2018-09-28 14:11:27 +0300
committerJari Vetoniemi <mailroxas@gmail.com>2018-09-28 14:11:27 +0300
commitce1a1ef4ba773de1e8dbce44db3f60cf9149acfa (patch)
tree76750a9a6efa66629c581015f9bdc85dd5ad8e02
parent56a17f4d966b2d53cd19a8ccc5ea237cd4cb13c2 (diff)
expr: fix || and && operations
-rw-r--r--src/compiler/expr.lm10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/compiler/expr.lm b/src/compiler/expr.lm
index b17cc39..89223d6 100644
--- a/src/compiler/expr.lm
+++ b/src/compiler/expr.lm
@@ -116,7 +116,7 @@ context collapser
next_is_unary:bool
literal `+ `-
- literal `( `) `+# `-# `! `~ `* `/ `% `#+ `#- `<< `>> `< `> `<= `>= `== `!= `& `^ `| `&& `|| `? `:
+ literal `( `) `+# `-# `! `~ `* `/ `% `#+ `#- `<< `>> `< `> `<= `>= `== `!= `&& `& `^ `|| `| `? `:
literal `. `[ `]
literal `sizeof
@@ -124,7 +124,7 @@ context collapser
[`!] | [`~]
def binary_unambi
- [`.] | [`*] | [`/] | [`%] | [`<<] | [`>>] | [`<] | [`>] | [`<=] | [`>=] | [`==] | [`!=] | [`&] | [`^] | [`|] | [`&&] | [`||]
+ [`.] | [`*] | [`/] | [`%] | [`<<] | [`>>] | [`<] | [`>] | [`<=] | [`>=] | [`==] | [`!=] | [`^] | [`&&] | [`&] | [`||] | [`|]
def ternary
[`:]
@@ -178,11 +178,11 @@ context collapser
| [number::type WS number::type WS `>=] { r:int = 0 if (r1.value >= r3.value) r = 1 lhs.value = parse value[$r] }
| [number::type WS number::type WS `==] { r:int = 0 if (r1.value == r3.value) r = 1 lhs.value = parse value[$r] }
| [number::type WS number::type WS `!=] { r:int = 0 if (r1.value != r3.value) r = 1 lhs.value = parse value[$r] }
+ | [number::type WS number::type WS `&&] { r:int = 0 if (r1.value && r3.value) r = 1 lhs.value = parse value[$r] }
| [number::type WS number::type WS `&] { lhs.value = parse value[$bitand(r1.value, r3.value)] }
| [number::type WS number::type WS `^] { lhs.value = parse value[$bitxor(r1.value, r3.value)] }
- | [number::type WS number::type WS `|] { lhs.value = parse value[$bitor(r1.value, r3.value)] }
- | [number::type WS number::type WS `&&] { r:int = 0 if (r1.value && r3.value) r = 1 lhs.value = parse value[$r] }
| [number::type WS number::type WS `||] { r:int = 0 if (r1.value || r3.value) r = 1 lhs.value = parse value[$r] }
+ | [number::type WS number::type WS `|] { lhs.value = parse value[$bitor(r1.value, r3.value)] }
| [number::type WS number::type WS number::type WS `:] { if (r1.value) lhs.value = parse value[$r3] else lhs.value = parse value[$r5] }
| [number::type WS value WS `]] commit { reject }
@@ -380,7 +380,7 @@ context collapser
[number::unsigned::type] | [string::type]
def tok#en
- [value WS+ value] commit { reject }
+ [value WS* value] commit { reject }
| [binary WS* binary] commit { reject }
| [constant WS* `(] commit { reject }
| [`) WS* value] commit { reject }