/**
* 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;
}
java类org.antlr.v4.runtime.tree.ParseTreeProperty的实例源码
UserAgentTreeFlattener.java 文件源码
项目:yauaa
阅读 24
收藏 0
点赞 0
评论 0
Listener.java 文件源码
项目:Reo
阅读 26
收藏 0
点赞 0
评论 0
/**
* 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>();
}
OTLDListener.java 文件源码
项目:transportlanguage
阅读 21
收藏 0
点赞 0
评论 0
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;
}
BramsprChecker.java 文件源码
项目:Bramspr
阅读 25
收藏 0
点赞 0
评论 0
/**
* 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;
}
CExpressionCompiler.java 文件源码
项目:udidb
阅读 20
收藏 0
点赞 0
评论 0
@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);
}
CExpressionCompiler.java 文件源码
项目:udidb
阅读 22
收藏 0
点赞 0
评论 0
@VisibleForTesting
static void typeCheckExpression(ParserRuleContext parseTree,
ParseTreeProperty<NodeState> states)
{
TypeCheckingVisitor typeCheckingVisitor = new TypeCheckingVisitor(states);
parseTree.accept(typeCheckingVisitor);
}
CExpressionCompiler.java 文件源码
项目:udidb
阅读 21
收藏 0
点赞 0
评论 0
@VisibleForTesting
static void simplifyExpression(ParserRuleContext parseTree,
ParseTreeProperty<NodeState> states,
ExecutionContext executionContext)
{
ExpressionSimplificationVisitor visitor = new ExpressionSimplificationVisitor(states, executionContext);
parseTree.accept(visitor);
}
CExpressionCompiler.java 文件源码
项目:udidb
阅读 21
收藏 0
点赞 0
评论 0
@VisibleForTesting
static Expression generateCode(ParserRuleContext parseTree,
ParseTreeProperty<NodeState> states,
ExecutionContext executionContext)
{
CodeGenVisitor visitor = new CodeGenVisitor(states, executionContext);
return parseTree.accept(visitor);
}
SymbolResolutionVisitor.java 文件源码
项目:udidb
阅读 18
收藏 0
点赞 0
评论 0
public SymbolResolutionVisitor(ParseTreeProperty<NodeState> states,
ExecutionContext executionContext,
Function currentFunction,
long pc)
{
super(states);
this.currentFunction = currentFunction;
this.pc = pc;
this.executable = executionContext.getExecutable();
}
SymbolResolutionVisitorTest.java 文件源码
项目:udidb
阅读 23
收藏 0
点赞 0
评论 0
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);
}
ExpressionSimplificationVisitorTest.java 文件源码
项目:udidb
阅读 20
收藏 0
点赞 0
评论 0
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);
}
ExpressionSimplificationVisitorTest.java 文件源码
项目:udidb
阅读 24
收藏 0
点赞 0
评论 0
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);
}
OboParserListener.java 文件源码
项目:ontolib
阅读 18
收藏 0
点赞 0
评论 0
/**
* Flush the {@link #values} mapping for allowing garbage collection.
*/
void clearValues() {
values = new ParseTreeProperty<>();
}
OboParserListener.java 文件源码
项目:boqa
阅读 18
收藏 0
点赞 0
评论 0
/**
* Flush the {@link #values} mapping for allowing garbage collection.
*/
void clearValues() {
values = new ParseTreeProperty<>();
}
PipelineRuleParser.java 文件源码
项目:graylog-plugin-pipeline-processor
阅读 24
收藏 0
点赞 0
评论 0
public ParseTreeProperty<Expression> expressions() {
return exprs;
}
PipelineRuleParser.java 文件源码
项目:graylog-plugin-pipeline-processor
阅读 20
收藏 0
点赞 0
评论 0
public ParseTreeProperty<Map<String, Expression>> arguments() {
return args;
}
PipelineRuleParser.java 文件源码
项目:graylog-plugin-pipeline-processor
阅读 22
收藏 0
点赞 0
评论 0
public ParseTreeProperty<List<Expression>> argumentLists() {
return argsLists;
}
NaiveInterpreterVisitor.java 文件源码
项目:arithmetic
阅读 25
收藏 0
点赞 0
评论 0
protected ParseTreeProperty<Double> getNumberNodesAnnotations() {
return numberNodesAnnotations;
}
NaiveInterpreterVisitor.java 文件源码
项目:arithmetic
阅读 23
收藏 0
点赞 0
评论 0
protected void setNumberNodesAnnotations(
ParseTreeProperty<Double> numberNodesAnnotations) {
this.numberNodesAnnotations = numberNodesAnnotations;
}
CodeGenVisitor.java 文件源码
项目:udidb
阅读 23
收藏 0
点赞 0
评论 0
public CodeGenVisitor(ParseTreeProperty<NodeState> states, ExecutionContext executionContext)
{
super(states);
this.executionContext = executionContext;
}
TypeCheckingVisitor.java 文件源码
项目:udidb
阅读 18
收藏 0
点赞 0
评论 0
public TypeCheckingVisitor(ParseTreeProperty<NodeState> states)
{
super(states);
}
ExpressionSimplificationVisitor.java 文件源码
项目:udidb
阅读 17
收藏 0
点赞 0
评论 0
public ExpressionSimplificationVisitor(ParseTreeProperty<NodeState> states, ExecutionContext executionContext)
{
super(states);
this.executionContext = executionContext;
}
BaseExpressionVisitor.java 文件源码
项目:udidb
阅读 23
收藏 0
点赞 0
评论 0
protected BaseExpressionVisitor(ParseTreeProperty<NodeState> states)
{
this.states = states;
}
TypeCheckingVisitorTest.java 文件源码
项目:udidb
阅读 23
收藏 0
点赞 0
评论 0
private static TypeCheckingVisitor createVisitor() throws Exception
{
ParseTreeProperty<NodeState> states = new ParseTreeProperty<>();
return new TypeCheckingVisitor(states);
}
RegexParser.java 文件源码
项目:apt
阅读 19
收藏 0
点赞 0
评论 0
private RegexListener(Set<Symbol> alphabet) {
this.automatons = new ParseTreeProperty<>();
this.automaton = null;
this.alphabet = alphabet;
}
SemanticListener.java 文件源码
项目:MatrixC
阅读 22
收藏 0
点赞 0
评论 0
public SemanticListener(List<Symbol> builtinDeclarations) {
this.semanticErrors = new LinkedList<>();
this.expressionTypes = new ParseTreeProperty<>();
this.functions = new ParseTreeProperty<>();
this.builtinDeclarations = builtinDeclarations;
}