Exemple #1
0
 def test_literal(self):
     '''
     Simple literal should compile directly.
     '''
     token = Token(Literal('abc'))
     token.compile()
     assert token.regexp == 'abc', repr(token.regexp)
Exemple #2
0
 def test_literal(self):
     '''
     Simple literal should compile directly.
     '''
     token = Token(Literal('abc'))
     token.compile()
     assert token.regexp == 'abc', repr(token.regexp)
Exemple #3
0
 def test_float(self):
     '''
     A float is more complex, but still compiles.
     '''
     token = Token(Float())
     token.compile()
     assert token.regexp == \
         '(?:[\\+\\-])?(?:(?:[0-9](?:[0-9])*)?\\.[0-9](?:[0-9])*|[0-9](?:[0-9])*(?:\\.)?)(?:[Ee](?:[\\+\\-])?[0-9](?:[0-9])*)?', \
         repr(token.regexp)
Exemple #4
0
 def test_impossible(self):
     '''
     Cannot compile arbitrary functions.
     '''
     try:
         token = Token(Float() > (lambda x: x))
         token.compile()
         assert False, 'Expected error'
     except LexerError:
         pass
Exemple #5
0
 def test_impossible(self):
     '''
     Cannot compile arbitrary functions.
     '''
     try:
         token = Token(Float() > (lambda x: x))
         token.compile()
         assert False, 'Expected error'
     except LexerError:
         pass
Exemple #6
0
 def test_float(self):
     '''
     A float is more complex, but still compiles.
     '''
     token = Token(Float())
     token.compile()
     assert token.regexp == \
         '([\\+\\-]|)(([0-9]([0-9])*|)\\.[0-9]([0-9])*|' \
         '[0-9]([0-9])*(\\.|))([Ee]([\\+\\-]|)[0-9]([0-9])*|)', \
         repr(token.regexp)