本文整理汇总了Python中lexer.Lexer.eatNum方法的典型用法代码示例。如果您正苦于以下问题:Python Lexer.eatNum方法的具体用法?Python Lexer.eatNum怎么用?Python Lexer.eatNum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lexer.Lexer
的用法示例。
在下文中一共展示了Lexer.eatNum方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from lexer import Lexer [as 别名]
# 或者: from lexer.Lexer import eatNum [as 别名]
#.........这里部分代码省略.........
tList.append(self.tableName())
return tList
def tableName(self):
alias = ''
name = self.lex.eatId()
if self.lex.matchKeyword('as'):
self.lex.eatKeyword('as')
alias = self.lex.eatId()
return {'tableName':name, 'alias':alias}
def predicate(self):
logic = ''
term2 = {}
term1 = self.term()
if self.lex.matchKeyword('and'):
logic = self.lex.eatKeyword('and')
term2 = self.term()
elif self.lex.matchKeyword('or'):
logic = self.lex.eatKeyword('or')
term2 = self.term()
return {'term1':term1, 'term2':term2, 'logic':logic}
def term(self):
exp1 = self.expression()
op = self.operator()
exp2 = self.expression()
return {'exp1': exp1, 'exp2': exp2, 'operator': op}
def expression(self):
if self.lex.matchId():
return self.projectField()
elif self.lex.matchNum():
return self.lex.eatNum()
else:
return '"'+self.lex.eatVarchar()+'"'
def operator(self):
op = ''
if self.lex.matchDelim('='):
op = self.lex.eatDelim('=')
elif self.lex.matchDelim('>'):
op = self.lex.eatDelim('>')
else:
op = self.lex.eatDelim('<')
if self.lex.matchDelim('>'):
op += self.lex.eatDelim('>')
return op
def create(self):
self.lex.eatKeyword('create')
return self.createTable()
def createTable(self):
self.lex.eatKeyword('table')
tableName = self.lex.eatId()
self.lex.eatDelim('(')
schema = self.fieldDefs()
self.lex.eatDelim(')')
return {'tableName':tableName, 'fields':schema.fields, 'primaryKey':schema.primaryKey}
def fieldDefs(self):
schema = self.fieldDef()
if self.lex.matchDelim(','):
self.lex.eatDelim(',')
schema2 = self.fieldDefs()