ideas, ideas.
This commit is contained in:
parent
4a78498133
commit
0638cfa187
@ -22,6 +22,7 @@ from hy.errors import HyError
|
|||||||
|
|
||||||
from hy.models.expression import HyExpression
|
from hy.models.expression import HyExpression
|
||||||
from hy.models.symbol import HySymbol
|
from hy.models.symbol import HySymbol
|
||||||
|
from hy.models.integer import HyInteger
|
||||||
from hy.models.string import HyString
|
from hy.models.string import HyString
|
||||||
|
|
||||||
import ast
|
import ast
|
||||||
@ -175,6 +176,12 @@ class HyASTCompiler(object):
|
|||||||
self.returnable = ret_status
|
self.returnable = ret_status
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
@builds(HyInteger)
|
||||||
|
def compile_number(self, number):
|
||||||
|
return ast.Num(n=number,
|
||||||
|
lineno=number.start_line,
|
||||||
|
col_offset=number.start_column)
|
||||||
|
|
||||||
@builds(HySymbol)
|
@builds(HySymbol)
|
||||||
def compile_symbol(self, symbol):
|
def compile_symbol(self, symbol):
|
||||||
return ast.Name(id=str(symbol), ctx=ast.Load(),
|
return ast.Name(id=str(symbol), ctx=ast.Load(),
|
||||||
|
@ -87,12 +87,14 @@ class Machine(object):
|
|||||||
if self.submachine:
|
if self.submachine:
|
||||||
self.submachine.process([char])
|
self.submachine.process([char])
|
||||||
if type(self.submachine.state) == Idle:
|
if type(self.submachine.state) == Idle:
|
||||||
if len(self.submachine.nodes) != 1:
|
if len(self.submachine.nodes) > 1:
|
||||||
raise LexException("Funky Submachine stuff")
|
raise LexException("Funky Submachine stuff")
|
||||||
result = self.submachine.nodes[0]
|
|
||||||
|
nodes = self.submachine.nodes
|
||||||
self.submachine = None
|
self.submachine = None
|
||||||
if result:
|
|
||||||
self.state.nodes.append(result)
|
if len(nodes) > 0:
|
||||||
|
self.state.nodes.append(nodes[0])
|
||||||
continue
|
continue
|
||||||
|
|
||||||
new = self.state.process(char)
|
new = self.state.process(char)
|
||||||
|
@ -120,7 +120,10 @@ class Expression(State):
|
|||||||
|
|
||||||
def exit(self):
|
def exit(self):
|
||||||
self.commit()
|
self.commit()
|
||||||
|
if self.nodes != []:
|
||||||
self.result = HyExpression(self.nodes)
|
self.result = HyExpression(self.nodes)
|
||||||
|
else:
|
||||||
|
self.result = None
|
||||||
|
|
||||||
def process(self, char):
|
def process(self, char):
|
||||||
"""
|
"""
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
#
|
||||||
|
|
||||||
|
import hy
|
||||||
|
from .native_tests.math import *
|
0
tests/native_tests/__init__.hy
Normal file
0
tests/native_tests/__init__.hy
Normal file
5
tests/native_tests/math.hy
Normal file
5
tests/native_tests/math.hy
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
; copyright ..
|
||||||
|
|
||||||
|
|
||||||
|
(def test_basic_math (fn ()
|
||||||
|
(assert (+ 2 2) 4)))
|
Loading…
Reference in New Issue
Block a user