Add .vimrc file. Some cleanup, formatting and comments
This commit is contained in:
parent
824d7ecd44
commit
de4efda63c
3 changed files with 12 additions and 3 deletions
4
.vimrc
Normal file
4
.vimrc
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
" Force indentation styles for this directory
|
||||
autocmd FileType python set shiftwidth=4
|
||||
autocmd FileType python set tabstop=4
|
||||
autocmd FileType python set softtabstop=4
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
# Chapter 1&2 - Lexer and Parser
|
||||
# Chapter 1 & 2 - Lexer and Parser
|
||||
|
||||
from collections import namedtuple
|
||||
from enum import Enum
|
||||
|
|
@ -156,7 +156,7 @@ class ParseError(Exception): pass
|
|||
|
||||
class Parser(object):
|
||||
"""Parser for the Kaleidoscope language.
|
||||
|
||||
|
||||
After the parser is created, invoke parse_toplevel multiple times to parse
|
||||
Kaleidoscope source into an AST.
|
||||
"""
|
||||
|
|
@ -457,5 +457,7 @@ class TestParser(unittest.TestCase):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# We just have the lexer and parser here, no code generation yet. This is
|
||||
# just a simple way to parse Kaleidoscope expressions and dump the AST.
|
||||
p = Parser()
|
||||
print(p.parse_toplevel('def bina(a b) a + b').dump())
|
||||
|
|
@ -173,7 +173,7 @@ class ParseError(Exception): pass
|
|||
|
||||
class Parser(object):
|
||||
"""Parser for the Kaleidoscope language.
|
||||
|
||||
|
||||
After the parser is created, invoke parse_toplevel multiple times to parse
|
||||
Kaleidoscope source into an AST.
|
||||
"""
|
||||
|
|
@ -553,6 +553,9 @@ class TestEvaluator(unittest.TestCase):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Example of how to define a couple of functions and then evaluate
|
||||
# expressions involving them. A single KaleidoscopeEvaluator object retains
|
||||
# its state across multiple calls to 'evaluate'.
|
||||
kalei = KaleidoscopeEvaluator()
|
||||
print(kalei.evaluate('def adder(a b) a + b'))
|
||||
print(kalei.evaluate('def foo(x) (1+2+x)*(x+(1+2))'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue