コード例 #1
0
 def __init__(self, variable):
     if re.match(r'^((GF|TF|LF)@[a-zA-Z_\-$&%*!?][a-zA-Z0-9_\-$&%*!?]*)$',
                 variable) is None:
         raise error.StructureError_32(variable)
     frame, name = variable.split('@', 2)
     self.frame = frame
     self.name = name
コード例 #2
0
 def boolean(self):
     """ Creates bool and returns it """
     if self.value == 'true':
         return True
     elif self.value == 'false':
         return False
     else:
         raise error.StructureError_32(self.value)
コード例 #3
0
    def string(self):
        """ Creates str and returns it """
        if self.value is None:
            self.value = ''
        if re.match(r'^(\\[0-9]{3}|[^\\#\s])*$', self.value) is None:  # TODO
            raise error.StructureError_32(self.value)

        escape = re.findall(r'\\[0-9]{3}', self.value)
        not_escape = re.split(r'\\[0-9]{3}', self.value)

        final_string = ''
        for not_esc, esc in zip(not_escape, escape):
            final_string += not_esc + chr(int(esc[1:]))
        final_string += not_escape[-1]

        return str(final_string)
コード例 #4
0
 def integer(self):
     """ Creates int and returns it """
     try:
         return int(self.value)
     except ValueError:
         raise error.StructureError_32(self.value)
コード例 #5
0
 def __init__(self, text):
     if text != 'nil':
         raise error.StructureError_32(text)
     self._nil = None
コード例 #6
0
 def __init__(self, name):
     if re.match(r'^([a-zA-Z_\-$&%*!?][a-zA-Z0-9_\-$&%*!?]*)$',
                 name) is None:
         raise error.StructureError_32(name)
     self._name = name
コード例 #7
0
 def __init__(self, typ):
     if typ not in {'int', 'bool', 'string'}:
         raise error.StructureError_32(typ)
     self._type = typ