本文整理汇总了Python中Block.Block.setSyntaxOnly方法的典型用法代码示例。如果您正苦于以下问题:Python Block.setSyntaxOnly方法的具体用法?Python Block.setSyntaxOnly怎么用?Python Block.setSyntaxOnly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Block.Block
的用法示例。
在下文中一共展示了Block.setSyntaxOnly方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: checkPart1
# 需要导入模块: from Block import Block [as 别名]
# 或者: from Block.Block import setSyntaxOnly [as 别名]
def checkPart1(self, test):
if (test[0] == '"' and test[len(test)-1] == '"'):
# this is a string literal
return self.checkStringLiteral(test)
elif (test[0] == '{' and test[len(test)-1] == '}'):
# this is a block
from Block import Block
#print test[0:len(test)]
b = Block(test[0:len(test)],self.getParent())
b.setSyntaxOnly(self.syntax_only)
if (b.checkSyntax()):
if(self.syntax_only == False):
self.property_list = b.property_list
return True
else:
return False
elif (test[0] == '(' and test[len(test)-1] == ')'):
# this is an expression
e = Expression(test[1:len(test)-1],self.getParent())
e.setSyntaxOnly(self.syntax_only)
if (e.checkSyntax()):
if(self.syntax_only == False):
self.property_list = e.property_list
return True
else:
return False
elif not (self.checkAsterisk(test)):
# this is a name with none or multiple *
print ("This is an invalid Expression: " + test)
return False
return True
示例2: concatenate
# 需要导入模块: from Block import Block [as 别名]
# 或者: from Block.Block import setSyntaxOnly [as 别名]
def concatenate(self,op1,op2,stars):
from Block import Block
tmp = None
if (len(op2.getDict()) == 1) and (self.isBlock(op2.getDict().values()[0])):
if (len(op1.getDict()) == 1) and (self.isBlock(op1.getDict().values()[0])):
raise KeyError
tmp = op2.getDict().values()[0]
if isinstance(self,Block):
newBlock = Block(tmp,self)
else:
newBlock = Block(tmp,self.getParent())
#print str(stars) + ":"
#print tmp
newBlock.setPropertyList(op1)
newBlock.setSyntaxOnly(self.syntax_only)
newBlock.setNested(stars)
newBlock.checkSyntax()
return newBlock.getPropertyList()
else:
#print "op2:"
#op2.printList()
return self.concatenatePropertyLists(op1, op2)
示例3: check
# 需要导入模块: from Block import Block [as 别名]
# 或者: from Block.Block import setSyntaxOnly [as 别名]
def check(path,syntaxOnly):
with open (path, "r") as myfile:
data=myfile.read()
data = removeComments(data)
#TODO now check Syntax
b = Block(data,None)
b.setSyntaxOnly(syntaxOnly)
return b.checkSyntax()