More cleanup + completeness mention in the README
This commit is contained in:
parent
de4efda63c
commit
7c7d2bc8e9
3 changed files with 23 additions and 13 deletions
|
|
@ -20,6 +20,10 @@ that exposes LLVM to Python. For tips on setting up ``llvmlite`` with LLVM, `see
|
||||||
this blog post
|
this blog post
|
||||||
<http://eli.thegreenplace.net/2015/building-and-using-llvmlite-a-basic-example/>`_.
|
<http://eli.thegreenplace.net/2015/building-and-using-llvmlite-a-basic-example/>`_.
|
||||||
|
|
||||||
|
This repository is fairly complete - the whole Kaleidoscope language is
|
||||||
|
implemented. The only thing missing is Chapter 8 - Debug Information, because
|
||||||
|
``llvlite`` does not yet support convenient emission of debug info.
|
||||||
|
|
||||||
How to use this code
|
How to use this code
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -559,5 +559,5 @@ if __name__ == '__main__':
|
||||||
kalei = KaleidoscopeEvaluator()
|
kalei = KaleidoscopeEvaluator()
|
||||||
print(kalei.evaluate('def adder(a b) a + b'))
|
print(kalei.evaluate('def adder(a b) a + b'))
|
||||||
print(kalei.evaluate('def foo(x) (1+2+x)*(x+(1+2))'))
|
print(kalei.evaluate('def foo(x) (1+2+x)*(x+(1+2))'))
|
||||||
print(kalei.evaluate('foo(3)', optimize=True, llvmdump=True))
|
print(kalei.evaluate('foo(3)'))
|
||||||
print(kalei.evaluate('foo(adder(3, 3)*4)', optimize=True, llvmdump=True))
|
print(kalei.evaluate('foo(adder(3, 3)*4)', optimize=True, llvmdump=True))
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ from enum import Enum
|
||||||
import llvmlite.ir as ir
|
import llvmlite.ir as ir
|
||||||
import llvmlite.binding as llvm
|
import llvmlite.binding as llvm
|
||||||
|
|
||||||
|
|
||||||
# Each token is a tuple of kind and value. kind is one of the enumeration values
|
# Each token is a tuple of kind and value. kind is one of the enumeration values
|
||||||
# in TokenKind. value is the textual value of the token in the input.
|
# in TokenKind. value is the textual value of the token in the input.
|
||||||
class TokenKind(Enum):
|
class TokenKind(Enum):
|
||||||
|
|
@ -785,6 +786,11 @@ class TestEvaluator(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
# Evaluate some code.
|
||||||
kalei = KaleidoscopeEvaluator()
|
kalei = KaleidoscopeEvaluator()
|
||||||
kalei.evaluate('def foo(a b) for x = 65, x < a, b in putchard(x)')
|
kalei.evaluate('def foo(a b) for x = 65, x < a, b in putchard(x)')
|
||||||
print(kalei.evaluate('foo(79, 1)', optimize=True, llvmdump=True))
|
|
||||||
|
# We call these for their side effect of printing to stdout, so don't care
|
||||||
|
# about the return value.
|
||||||
|
kalei.evaluate('foo(79, 1)')
|
||||||
|
kalei.evaluate('putchard(10)')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue