cleanup
This commit is contained in:
@ -69,6 +69,8 @@ object strtrait:
|
||||
|
||||
def add(other):
|
||||
self $str_add(other)
|
||||
def substr(s, e):
|
||||
self $str_subs(s, e)
|
||||
def rev:
|
||||
self $str_rev
|
||||
def len:
|
||||
|
@ -104,7 +104,7 @@ class PrimitiveObject(AbstractObject):
|
||||
|
||||
class W_Integer(PrimitiveObject):
|
||||
def __init__(self, value, space=None):
|
||||
super().__init__(int(value), "inttrait", space)
|
||||
super().__init__(int(value), "inttrait", space=space)
|
||||
|
||||
|
||||
class W_Boolean(PrimitiveObject):
|
||||
@ -119,12 +119,12 @@ class W_Boolean(PrimitiveObject):
|
||||
|
||||
class W_String(PrimitiveObject):
|
||||
def __init__(self, value, space=None):
|
||||
super().__init__(str(value), "strtrait", space)
|
||||
super().__init__(str(value), "strtrait", space=space)
|
||||
|
||||
|
||||
class W_Double(PrimitiveObject):
|
||||
def __init__(self, value, space=None):
|
||||
super().__init__(float(value), "doubletrait", space)
|
||||
super().__init__(float(value), "doubletrait", space=space)
|
||||
|
||||
|
||||
# -------------
|
||||
|
@ -173,6 +173,11 @@ def simple_str_add(a, b):
|
||||
return a + b
|
||||
|
||||
|
||||
@primitive("str_subs", [str, int, int], str)
|
||||
def simple_str_subs(a, s, e):
|
||||
return a[s:e]
|
||||
|
||||
|
||||
@primitive("str_rev", [str], str)
|
||||
def simple_str_eq(a):
|
||||
return a[::-1]
|
||||
|
@ -173,10 +173,10 @@ Plus = r'\+'
|
||||
Minus = r'-'
|
||||
Multiply = r'\*'
|
||||
Divide = r'/'
|
||||
Increment = r'\+\+'
|
||||
Decrement = r'--'
|
||||
Modulo = r'%'
|
||||
|
||||
Increment = r'\+\+'
|
||||
Decrement = r'--'
|
||||
PlusInplace = r'\+='
|
||||
MinusInplace = r'-='
|
||||
MultiplyInplace = r'\*='
|
||||
@ -206,15 +206,14 @@ Object = r'object'
|
||||
|
||||
tokens = ["If", "Else", "While", "Def", "Object", "Ignore",
|
||||
"String", "Boolean", "Double",
|
||||
"Number", # after Double
|
||||
"Number",
|
||||
"GC",
|
||||
"NewlineAndWhitespace", "OpenBracket", "CloseBracket", "Comma", "Colon",
|
||||
"And", "Or", "LessEqual", "Less", "GreaterEqual", "Greater", "Equal", "NotEqual",
|
||||
"Decrement", "PlusInplace", "MinusInplace", "MultiplyInplace", "DivideInplace",
|
||||
"Increment", "Plus", "Minus", "Multiply", "Divide", "Modulo",
|
||||
"Assign", "Not",
|
||||
"Name", "PrimitiveName",
|
||||
]
|
||||
"Name", "PrimitiveName"]
|
||||
|
||||
|
||||
def make_lexer():
|
||||
|
Reference in New Issue
Block a user