def _commitUnparsedStatment(model, value): withoutNewline = value[:-1] unparsed = Schema.UnparsedStmt(value=Schema.UNPARSED( value=withoutNewline.getItemValues())) # In some cases, we will be replacing @model with an UNPARSED node that contains a reference to @model. # Since pyReplaceNode calls model.become(), this causes severe problems, due to circular references. # The call to deepcopy eliminates this possibility. pyReplaceNode(model, deepcopy(unparsed))
def _commitExprOuterEmpty(model, parsed): model['expr'] = Schema.UNPARSED(value=[''])
def _commitTargetOuterUnparsed(model, value): values = value.getItemValues() if values == []: values = [''] model['target'] = Schema.UNPARSED(value=values)
def _commitTargetOuterEmpty(model, parsed): model['target'] = Schema.UNPARSED(value=[''])
def _commitExprOuterUnparsed(model, value): values = value.getItemValues() if values == []: values = [''] model['expr'] = Schema.UNPARSED(value=values)
def _py25NewTarget(): return Schema.PythonTarget( target=Schema.UNPARSED( value=[ '' ] ) )
def fromText(text): parseResult = _grammar.tupleOrExpressionOrYieldExpression().parseStringChars( text ) if parseResult.isValid(): return EmbeddedPython2Expr( Schema.PythonExpression( expr=parseResult.getValue() ) ) else: return EmbeddedPython2Expr( Schema.PythonExpression( expr=Schema.UNPARSED( value=[ text ] ) ) )
def fromText(text): parseResult = _grammar.targetListOrTargetItem().parseStringChars( text ) if parseResult.isValid(): return EmbeddedPython2Target( Schema.PythonTarget( target=parseResult.getValue() ) ) else: return EmbeddedPython2Target( Schema.PythonTarget( target=Schema.UNPARSED( value=[ text ] ) ) )