Exemple #1
0
def t_REAL8(t):
    r'0[1-7][0-7]*\.[0-7]+|00+\.[0-7]+'
    # 匹配整数部分非0的八进制小数
    # 匹配整数部分非0的八进制小数
    t.value = oct_to_dec(t.value)
    t.value = float(t.value)
    return t
Exemple #2
0
 def test_REAL8(self):
     self.lexer.input("0712.726")
     print("Test No.5: REAL8 with input 0712.726")
     tok = lex.token()
     print(repr(tok.type), repr(tok.value))
     self.assertEqual(tok.type, 'REAL8')
     self.assertEqual(tok.value, oct_to_dec("0712.726"))
     print("Test end.")
     pass
Exemple #3
0
 def test_INT8(self):
     # 将 060 输入lexer
     self.lexer.input("060")
     print("Test No.2: INT8 with input 060")
     tok = lex.token()
     print(repr(tok.type), repr(tok.value))
     # 判断词法分析的类型是否等于INT8
     self.assertEqual(tok.type, 'INT8')
     # 判断词法分析的值知否等于 060 的十进制数值
     self.assertEqual(tok.value, oct_to_dec("060"))
     print("Test end.")
     pass
Exemple #4
0
def t_INT8(t):
    r'0[0-7]+|000*'
    t.value = oct_to_dec(t.value)
    t.value = int(t.value)
    return t