Example usage for org.antlr.v4.runtime.tree ParseTreeProperty ParseTreeProperty

List of usage examples for org.antlr.v4.runtime.tree ParseTreeProperty ParseTreeProperty

Introduction

In this page you can find the example usage for org.antlr.v4.runtime.tree ParseTreeProperty ParseTreeProperty.

Prototype

ParseTreeProperty

Source Link

Usage

From source file:com.imag.nespros.runtime.lang.ESCBuilder.java

public ESCBuilder() {
    operators = new ParseTreeProperty<>();
    filters = new ParseTreeProperty<>();
    windows = new ParseTreeProperty<>();
    id2Operator = new FastHashMap<>();
}

From source file:de.dfki.kiara.idl.KiaraKTDConstructor.java

License:Open Source License

public KiaraKTDConstructor(Module module, String fileName) {
    this.values = new ParseTreeProperty<>();
    this.module = module;
    this.parserErrors = new ArrayList<>();
    this.fileName = fileName;
}

From source file:edu.clemson.cs.rsrg.parsing.TreeBuildingListener.java

License:Open Source License

/**
 * <p>Create a listener to walk the entire compiler generated
 * ANTLR4 parser tree and generate the intermediate representation
 * objects used by the subsequent modules.</p>
 *
 * @param file The current file we are compiling.
 * @param typeGraph Type graph that indicates relationship between different mathematical types.
 *///from  w ww .  ja  v  a2 s.co m
public TreeBuildingListener(ResolveFile file, TypeGraph typeGraph) {
    myTypeGraph = typeGraph;
    myFile = file;
    myFinalModule = null;
    myNodes = new ParseTreeProperty<>();
    myDefinitionMemberList = null;
    myIsProcessingModuleArgument = false;
    myModuleLevelDecs = null;
    myArrayFacilityDecContainerStack = new Stack<>();
    myArrayNameTyToInnerTyMap = new LinkedHashMap<>();
    myCopyTRList = new ArrayList<>();
    myCopySSRList = new ArrayList<>();
    myNewElementCounter = 0;
    myModuleDependencies = new LinkedHashMap<>();
}

From source file:net.certiv.json.converter.JsonPhase01.java

License:Open Source License

/**
 * Phase Plan: <br>/*from ww w . j  a v a2  s. c o m*/
 * -- create typed descriptor objects for context instances <br>
 * -- if enabled, examine and collect comments from hidden-channel <br>
 * -- initialize descriptors <br>
 * -- where the descriptor is contextually complete, mark the descriptor 'resolved' <br>
 * 
 * @param processor
 */
public JsonPhase01(PhaseState state, IOProcessor processor) {
    super(state, processor);
    this.state.nodeContextMap = new ParseTreeProperty<BaseDescriptor>();
    this.state.commentMarkers = new ArrayList<Integer>();
    Log.info(this, "Phase " + phase + ": Starting...");
}

From source file:net.cpollet.thorium.analysis.ParseTreeTypes.java

License:Apache License

public ParseTreeProperty<Type> reduce() {
    ParseTreeProperty<Type> result = new ParseTreeProperty<>();

    annotations.forEach((parseTree, types) -> {
        if (types.size() != 1) {
            result.put(parseTree, Types.NULLABLE_VOID);
        } else {/*from w  w w.  ja v a2  s  .c  o  m*/
            result.put(parseTree, types.iterator().next());
        }
    });

    return result;
}

From source file:net.udidb.expr.lang.c.CExpressionCompiler.java

License:Open Source License

@VisibleForTesting
Expression compile(String expression, ExecutionContext executionContext, boolean displayTree)
        throws ExpressionException {
    long pc = 0;/*from   w  ww . ja va  2  s. c  o m*/
    Function currentFunction = null;
    if (!executionContext.getCurrentThread().getParentProcess().isWaitingForStart()) {
        try {
            pc = executionContext.getCurrentThread().getPC();
        } catch (UdiException e) {
            throw new ExpressionException(e);
        }
        currentFunction = executionContext.getExecutable().getContainingFunction(pc);
    }

    final ParseTreeProperty<NodeState> states = new ParseTreeProperty<>();

    // Parse the expression
    final CParser parser;
    try {
        parser = createParser(expression);
    } catch (IOException e) {
        throw new ExpressionException(e);
    }
    ParserRuleContext parseTree = parser.expression();

    // Resolve all symbols, interrogating the debuggee as necessary
    resolveSymbols(parseTree, states, executionContext, currentFunction, pc);

    // Type checking
    typeCheckExpression(parseTree, states);

    // Simplify the expression given the current state of the AST
    simplifyExpression(parseTree, states, executionContext);

    // Generate code and produce Expression to encapsulate the result
    Expression output = generateCode(parseTree, states, executionContext);

    if (displayTree) {
        TreeViewer viewer = new TreeViewer(Arrays.asList(parser.getRuleNames()), parseTree);
        viewer.setTreeTextProvider(new TreeTextProvider() {
            TreeTextProvider defaultProvider = new DefaultTreeTextProvider(
                    Arrays.asList(parser.getRuleNames()));

            @Override
            public String getText(Tree node) {
                if (node instanceof ParseTree) {
                    NodeState nodeState = states.get((ParseTree) node);

                    ExpressionValue value;
                    if (nodeState != null) {
                        value = nodeState.getExpressionValue();
                    } else {
                        value = null;
                    }

                    if (value != null) {
                        return defaultProvider.getText(node) + "(" + value + ")";
                    } else {
                        return defaultProvider.getText(node) + "(null)";
                    }
                }

                return defaultProvider.getText(node);
            }
        });
        viewer.open();
    }

    return output;
}

From source file:nl.basjes.parse.useragent.parse.UserAgentTreeFlattener.java

License:Apache License

/**
 * 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
 *///from   ww w  .j av a2 s  .c o  m
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;
}

From source file:org.smallpearl.compiler.ConstantPoolVisitor.java

License:BSD License

public ConstantPoolVisitor(int verbose, boolean debug) {

    m_verbose = verbose;/*w  w  w .j  a  v  a2s . c om*/
    m_debug = debug;

    if (m_verbose > 0) {
        System.out.println("Semantic Check: Create ConstantPool");
    }

    if (m_debug) {
        System.out.println("Semantic Check: Enabled debugging information");
    }

    m_properties = new ParseTreeProperty<TypeDefinition>();

    // Add commonly used constants:
    add(new ConstantFixedValue(0));
    add(new ConstantFixedValue(1));
    add(new ConstantFixedValue(-1));
}

From source file:org.smallpearl.compiler.ExpressionTypeVisitor.java

License:BSD License

public ExpressionTypeVisitor(int verbose, boolean debug) {

    m_verbose = verbose;/*from www .j  av a 2  s. c o m*/
    m_debug = debug;

    if (m_verbose > 0) {
        System.out.println("Semantic Check: Attributing parse tree with expression type information");
    }

    if (m_debug) {
        System.out.println("Semantic Check: Enabled debugging information");
    }

    m_properties = new ParseTreeProperty<TypeDefinition>();
}