use of org.finos.legend.engine.language.pure.grammar.from.PureGrammarParserContext in project legend-engine by finos.
the class DomainParser method parseValueSpecification.
public ValueSpecification parseValueSpecification(String input, String s, boolean returnSourceInfo) {
PureGrammarParserContext parserContext = new PureGrammarParserContext(PureGrammarParserExtensions.fromExtensions(Lists.immutable.empty()));
ParseTreeWalkerSourceInformation lambdaWalkerSourceInformation = new ParseTreeWalkerSourceInformation.Builder(s, 0, 0).withReturnSourceInfo(returnSourceInfo).build();
String prefix = "function go():Any[*]{let x = ";
String fullCode = prefix + input + ";}";
ParseTreeWalkerSourceInformation walkerSourceInformation = new ParseTreeWalkerSourceInformation.Builder(lambdaWalkerSourceInformation).withColumnOffset(lambdaWalkerSourceInformation.getColumnOffset() - prefix.length()).build();
SourceCodeParserInfo sectionParserInfo = this.getParserInfo(fullCode, null, walkerSourceInformation, true);
DomainParseTreeWalker walker = new DomainParseTreeWalker(walkerSourceInformation, parserContext, (ImportAwareCodeSection) null);
return (ValueSpecification) walker.combinedExpression(((DomainParserGrammar.DefinitionContext) sectionParserInfo.rootContext).elementDefinition(0).functionDefinition().codeBlock().programLine(0).letExpression().combinedExpression(), "", Lists.mutable.empty(), null, "", false, returnSourceInfo);
}
Aggregations