Skip to content

Commit

Permalink
handle basic expression compilation (targeting C)
Browse files Browse the repository at this point in the history
  • Loading branch information
generic-github-user committed Sep 20, 2022
1 parent 8f9e3a3 commit 626035a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion finch/compiler/cinch.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ class ArgumentError(Exception):
tree = parse(tokens)
# print(tree)
tree.print()

print(tree.compile())

12 changes: 12 additions & 0 deletions finch/compiler/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,25 @@ class Int(Literal):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def compile(self):
return self[0].content


class Float(Literal):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def compile(self):
return self[0].content


class Tuple(Expression):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def compile(self):
return ", ".join(x.compile() for x in self.children)


class Array(Expression):
def __init__(self, *args, **kwargs):
Expand All @@ -82,6 +91,9 @@ class Symbol(Expression):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def compile(self):
return self[0].content


class Operation(Expression):
def __init__(self, *args, **kwargs):
Expand Down

0 comments on commit 626035a

Please sign in to comment.