本文整理汇总了Java中org.antlr.v4.runtime.tree.ParseTreeProperty类的典型用法代码示例。如果您正苦于以下问题:Java ParseTreeProperty类的具体用法?Java ParseTreeProperty怎么用?Java ParseTreeProperty使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParseTreeProperty类属于org.antlr.v4.runtime.tree包,在下文中一共展示了ParseTreeProperty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseIntoCleanUserAgent
import org.antlr.v4.runtime.tree.ParseTreeProperty; //导入依赖的package包/类
/**
* Parse the useragent and return every part that was found.
*
* @param userAgent The useragent instance that needs to be parsed
* @return If the parse was valid (i.e. were there any parser errors: true=valid; false=has errors
*/
private UserAgent parseIntoCleanUserAgent(UserAgent userAgent) {
if (userAgent.getUserAgentString() == null) {
userAgent.set(SYNTAX_ERROR, "true", 1);
return userAgent; // Cannot parse this
}
// Parse the userAgent into tree
UserAgentContext userAgentContext = parseUserAgent(userAgent);
// Walk the tree an inform the calling analyzer about all the nodes found
state = new ParseTreeProperty<>();
State rootState = new State("agent");
rootState.calculatePath(PathType.CHILD, false);
state.put(userAgentContext, rootState);
if (userAgent.hasSyntaxError()) {
inform(null, SYNTAX_ERROR, "true");
} else {
inform(null, SYNTAX_ERROR, "false");
}
WALKER.walk(this, userAgentContext);
return userAgent;
}
示例2: setFileName
import org.antlr.v4.runtime.tree.ParseTreeProperty; //导入依赖的package包/类
/**
* Sets the file name, and clears all parse tree properties.
*/
public void setFileName(String filename) {
this.filename = filename;
imports.clear();
section = new ParseTreeProperty<String>();
components = new ParseTreeProperty<ComponentExpression<T>>();
formula = new ParseTreeProperty<PredicateExpression>();
instances = new ParseTreeProperty<InstanceExpression<T>>();
terms = new ParseTreeProperty<TermExpression>();
termsList = new ParseTreeProperty<List<TermExpression>>();
signatureExpressions = new ParseTreeProperty<SignatureExpression>();
parameterlists = new ParseTreeProperty<List<ParameterExpression>>();
parameters = new ParseTreeProperty<ParameterExpression>();
nodelists = new ParseTreeProperty<List<NodeExpression>>();
nodes = new ParseTreeProperty<NodeExpression>();
typetags = new ParseTreeProperty<TypeTag>();
portlists = new ParseTreeProperty<List<PortExpression>>();
ports = new ParseTreeProperty<PortExpression>();
variables = new ParseTreeProperty<VariableExpression>();
atoms = new ParseTreeProperty<T>();
}
示例3: OTLDListener
import org.antlr.v4.runtime.tree.ParseTreeProperty; //导入依赖的package包/类
public OTLDListener() {
this.functions = new ParseTreeProperty<>();
this.conditionals = new ParseTreeProperty<>();
this.stack = new Stack<>();
this.errors = new ArrayList<>();
this.waypoints = new HashMap<>();
this.lastFunction = null;
}
示例4: check
import org.antlr.v4.runtime.tree.ParseTreeProperty; //导入依赖的package包/类
/**
* Starts the context checking.
*
* Will print out the amount of errors afterwards. If there were any errors, calls {@link System#exit System.exit}.
*
* @param tree
* The parse tree to be context checked.
* @return {@link #parseTreeDecoration}
*/
public ParseTreeProperty<Symbol> check(ParseTree tree) {
this.parseTreeDecoration = new ParseTreeProperty<Symbol>();
this.visit(tree);
if (this.getErrorCount() > 0) {
System.err.println("There were " + this.getErrorCount() + " errors detected.");
System.err.println("Aborting compilation: cannot compile code with errors.");
System.exit(1); // Did not compile correctly
}
return this.parseTreeDecoration;
}
示例5: resolveSymbols
import org.antlr.v4.runtime.tree.ParseTreeProperty; //导入依赖的package包/类
@VisibleForTesting
static void resolveSymbols(ParserRuleContext parseTree,
ParseTreeProperty<NodeState> states,
ExecutionContext executionContext,
Function currentFunction,
long pc)
{
SymbolResolutionVisitor resolutionVisitor = new SymbolResolutionVisitor(states, executionContext, currentFunction, pc);
parseTree.accept(resolutionVisitor);
}
示例6: typeCheckExpression
import org.antlr.v4.runtime.tree.ParseTreeProperty; //导入依赖的package包/类
@VisibleForTesting
static void typeCheckExpression(ParserRuleContext parseTree,
ParseTreeProperty<NodeState> states)
{
TypeCheckingVisitor typeCheckingVisitor = new TypeCheckingVisitor(states);
parseTree.accept(typeCheckingVisitor);
}
示例7: simplifyExpression
import org.antlr.v4.runtime.tree.ParseTreeProperty; //导入依赖的package包/类
@VisibleForTesting
static void simplifyExpression(ParserRuleContext parseTree,
ParseTreeProperty<NodeState> states,
ExecutionContext executionContext)
{
ExpressionSimplificationVisitor visitor = new ExpressionSimplificationVisitor(states, executionContext);
parseTree.accept(visitor);
}
示例8: generateCode
import org.antlr.v4.runtime.tree.ParseTreeProperty; //导入依赖的package包/类
@VisibleForTesting
static Expression generateCode(ParserRuleContext parseTree,
ParseTreeProperty<NodeState> states,
ExecutionContext executionContext)
{
CodeGenVisitor visitor = new CodeGenVisitor(states, executionContext);
return parseTree.accept(visitor);
}
示例9: SymbolResolutionVisitor
import org.antlr.v4.runtime.tree.ParseTreeProperty; //导入依赖的package包/类
public SymbolResolutionVisitor(ParseTreeProperty<NodeState> states,
ExecutionContext executionContext,
Function currentFunction,
long pc)
{
super(states);
this.currentFunction = currentFunction;
this.pc = pc;
this.executable = executionContext.getExecutable();
}
示例10: createVisitor
import org.antlr.v4.runtime.tree.ParseTreeProperty; //导入依赖的package包/类
private static SymbolResolutionVisitor createVisitor() throws Exception
{
ExecutionContext executionContext = mock(ExecutionContext.class);
Function currentFunction = mock(Function.class);
ParseTreeProperty<NodeState> states = new ParseTreeProperty<>();
return new SymbolResolutionVisitor(states, executionContext, currentFunction, 0);
}
示例11: runSimplification
import org.antlr.v4.runtime.tree.ParseTreeProperty; //导入依赖的package包/类
private void runSimplification(ParserRuleContext parseTree,
ParseTreeProperty<NodeState> states,
ExecutionContext executionContext) throws Exception
{
long pc = executionContext.getCurrentThread().getPC();
Function currentFunction = executionContext.getExecutable().getContainingFunction(pc);
CExpressionCompiler.resolveSymbols(parseTree, states, executionContext, currentFunction, pc);
CExpressionCompiler.typeCheckExpression(parseTree, states);
CExpressionCompiler.simplifyExpression(parseTree, states, executionContext);
}
示例12: testSimplification
import org.antlr.v4.runtime.tree.ParseTreeProperty; //导入依赖的package包/类
private void testSimplification(String input, String output, ExecutionContext executionContext) throws Exception
{
ParseTreeProperty<NodeState> states = new ParseTreeProperty<>();
ParserRuleContext parseTree = CExpressionCompiler.createParseTree(input);
runSimplification(parseTree, states, executionContext);
NodeState nodeState = states.get(parseTree);
assertNotNull(nodeState);
assertNotNull(nodeState.getExpressionValue());
assertEquals(nodeState.getExpressionValue().toString(), output);
}
示例13: clearValues
import org.antlr.v4.runtime.tree.ParseTreeProperty; //导入依赖的package包/类
/**
* Flush the {@link #values} mapping for allowing garbage collection.
*/
void clearValues() {
values = new ParseTreeProperty<>();
}
示例14: expressions
import org.antlr.v4.runtime.tree.ParseTreeProperty; //导入依赖的package包/类
public ParseTreeProperty<Expression> expressions() {
return exprs;
}
示例15: arguments
import org.antlr.v4.runtime.tree.ParseTreeProperty; //导入依赖的package包/类
public ParseTreeProperty<Map<String, Expression>> arguments() {
return args;
}