Example #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])
Example #2
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(';')
Example #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(';')