示例#1
0
 def test_escape(self):
     """test : escape"""
     cases = zip(list('abcde'), list('abcde')) + \
         zip('()|*\\ea',
             ['\(', '\)', '\|', '\*', '\\\\', 'e', 'a'])
     for case in cases:
         self.assertEqual(yare.escape(case[0]), case[1])
示例#2
0
文件: cmm_lex.py 项目: hsinhuang/yaly
    '\'',
])

def t_COMMENT(t):
    t.lexer.lineno += 1
    t.skip = True
    return t
t_COMMENT.__doc__ = yare.concat([
    '/',
    '/',
    yare.loop(yare.diff(['\n'])),
    '\n',
])

# Operators
t_ASSIGN = yare.escape('=')
t_PLUS = yare.escape('+')
t_MINUS = yare.escape('-')
t_TIMES = yare.escape('*')
t_DIVIDE = yare.escape('/')
t_OR = yare.concat(list('||'))
t_AND = yare.concat(list('&&'))
t_NOT = yare.escape('!')
t_LT = yare.escape('<')
t_GT = yare.escape('>')
t_LE = yare.concat(list('<='))
t_GE = yare.concat(list('>='))
t_EQ = yare.concat(list('=='))
t_NE = yare.concat(list('!='))
t_COMMA = yare.escape(',')
t_SEMI = yare.escape(';')
示例#3
0
def t_COMMENT(t):
    t.lexer.lineno += 1
    t.skip = True
    return t


t_COMMENT.__doc__ = yare.concat([
    '/',
    '/',
    yare.loop(yare.diff(['\n'])),
    '\n',
])

# Operators
t_ASSIGN = yare.escape('=')
t_PLUS = yare.escape('+')
t_MINUS = yare.escape('-')
t_TIMES = yare.escape('*')
t_DIVIDE = yare.escape('/')
t_OR = yare.concat(list('||'))
t_AND = yare.concat(list('&&'))
t_NOT = yare.escape('!')
t_LT = yare.escape('<')
t_GT = yare.escape('>')
t_LE = yare.concat(list('<='))
t_GE = yare.concat(list('>='))
t_EQ = yare.concat(list('=='))
t_NE = yare.concat(list('!='))
t_COMMA = yare.escape(',')
t_SEMI = yare.escape(';')