summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2018-09-26 16:02:30 +0300
committerJari Vetoniemi <mailroxas@gmail.com>2018-09-26 16:02:30 +0300
commit633e1675839b0dc6484a6b9ca4b3a68e3a3be8f6 (patch)
tree04637b3b4d2863b8f06f8296e8adf819eeefc3c6
parent7c6ac33968a303f43204a039c00ccddd7faa1497 (diff)
Print out select expression information
-rw-r--r--src/compiler/compiler.lm25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/compiler/compiler.lm b/src/compiler/compiler.lm
index 33dd2c3..4ed772b 100644
--- a/src/compiler/compiler.lm
+++ b/src/compiler/compiler.lm
@@ -45,6 +45,7 @@ context fspec
def type
name:str
items:item+
+ select:expr::paren::type
[type:`enum WS+ name::type? `{ item+ `}] { if (name::type in r3) lhs.name = $(name::type in r3) lhs.items = r5 }
end
@@ -62,6 +63,7 @@ context fspec
def type
name:str
items:item+
+ select:expr::paren::type
[type:`struct WS+ name::type? `{ item+ `}] { if (name::type in r3) lhs.name = $(name::type in r3) lhs.items = r5 }
end
@@ -80,7 +82,8 @@ context fspec
def type
name:str
items:item+ # BUG: marking item+ with items: in the match below causes weird behaviour
- [type:`select `( expr::paren::type `) `{ item+ `}] { lhs.items = r6 }
+ select:expr::paren::type
+ [type:`select `( expr::paren::type `) `{ item+ `}] { lhs.select = r3 lhs.items = r6 }
end
def type
@@ -238,9 +241,13 @@ print_declaration(d:fspec::declaration::type)
c:fspec::container::type
if (d.cref) c = lookup($d.cref, $d.parent) else c = d.container
- if (c)
+ if (c) {
print('`', c.data.type, ' ', container_name_str(c.data.name), '` ')
+ if (c.data.select)
+ print('with expression `', $c.data.select, '` ')
+ }
+
if (d.primitive)
print(d.primitive.bits, ' bits and ', signed_str(d.primitive.signed))
@@ -272,25 +279,29 @@ walk(s:fspec::container::type)
{
insert($s.data.type, s.data.name, s)
if ($s.data.type == 'enum') {
- for i:fspec::container::enum::item in repeat(s.data.items)
+ for i:fspec::container::enum::item in repeat(s.data.items) {
+ print('constant `', $i.name, '` = ', $i.value, '\n')
insert('variable', $i.name, i)
+ }
} else if ($s.data.type == 'struct') {
push_scope()
for d:fspec::container::strukt::item in repeat(s.data.items) {
- if (d.data.container)
- walk(d.data.container)
if (d.data.name)
print_declaration(d.data)
+ if (d.data.container)
+ walk(d.data.container)
}
pop_scope()
} else if ($s.data.type == 'select') {
push_scope()
for d:fspec::container::select::item in repeat(s.data.items) {
- if (d.data.container)
- walk(d.data.container)
+ print('━━━━ ', $d.expr, ' ━━━━\n')
if (d.data.name)
print_declaration(d.data)
+ if (d.data.container)
+ walk(d.data.container)
}
+ print('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n')
pop_scope()
}
}