Beispiel #1
0
 def boolLit(self, node, children):
     'boolLit = _("#t" / "#f")_'
     if (node.text == "#t"):
         return True
     else:
         return False
     return typecheck.Const(node.text, typecheck.Bool)
Beispiel #2
0
 def complexLit(
     self, node, children
 ):  #bit of a mess: complexLit = optional "-", (float or integer), "+" or "-", (float or integer)
     'complexLit = ("+"/"-")? (numeral ("." numeral)?) ("+"/"-") (numeral ("." numeral)?) "i"'
     return typecheck.Const(node.text, typecheck.Complex)
Beispiel #3
0
 def floatLit(self, node, children):
     'floatLit = ("-")? numeral "." numeral '
     return typecheck.Const(node.text, typecheck.Float)
Beispiel #4
0
 def intLit(self, node, children):
     'intLit = ("-")? numeral'
     return typecheck.Const(node.text, typecheck.Int)
Beispiel #5
0
 def stringLit(self, node, children):
     'stringLit = "\\"" ~"[a-z A-Z 0-9 ! # $ ?]*" "\\"" '
     return typecheck.Const(node.text, typecheck.String)
Beispiel #6
0
 def lista(self, node, children):
     'lista = "[" expr* "]"'
     _, arguments, _ = children
     typos = tsek.parseAndGenerateListType(node.text)
     return typecheck.Const(str(arguments), typos)
Beispiel #7
0
 def lista(self, node, children):
     'lista = "[" expr* "]"'
     _, arguments, _ = children
     return typecheck.Const(str(arguments), typecheck.Qubit)