Package org.jostraca.comp.antlr.collections.impl

Examples of org.jostraca.comp.antlr.collections.impl.Vector


    /** Generate the lexer Java file */
    public void gen(LexerGrammar g) throws IOException {
        // If debugging, create a new sempred vector for this grammar
        if (g.debuggingOutput)
            semPreds = new Vector();

        setGrammar(g);
        if (!(grammar instanceof LexerGrammar)) {
            antlrTool.panic("Internal error generating lexer");
        }
View Full Code Here


    public void gen(ParserGrammar g) throws IOException {

        // if debugging, set up a new vector to keep track of sempred
        //   strings for this grammar
        if (g.debuggingOutput)
            semPreds = new Vector();

        setGrammar(g);
        if (!(grammar instanceof ParserGrammar)) {
            antlrTool.panic("Internal error generating parser");
        }
View Full Code Here

        println("public static final String[] _tokenNames = {");
        tabs++;

        // Walk the token vocabulary and generate a Vector of strings
        // from the tokens.
        Vector v = grammar.tokenManager.getVocabulary();
        for (int i = 0; i < v.size(); i++) {
            String s = (String)v.elementAt(i);
            if (s == null) {
                s = "<" + String.valueOf(i) + ">";
            }
            if (!s.startsWith("\"") && !s.startsWith("<")) {
                TokenSymbol ts = (TokenSymbol)grammar.tokenManager.getTokenSymbol(s);
                if (ts != null && ts.getParaphrase() != null) {
                    s = StringUtils.stripFrontBack(ts.getParaphrase(), "\"", "\"");
                }
            }
            print(charFormatter.literalString(s));
            if (i != v.size() - 1) {
                _print(",");
            }
            _println("");
        }
View Full Code Here

    // if heterogeneous node known for that token T.
        tabs++;
    boolean generatedNewHashtable = false;
    int n = 0;
        // Walk the token vocabulary and generate puts.
    Vector v = grammar.tokenManager.getVocabulary();
    for (int i = 0; i < v.size(); i++) {
      String s = (String)v.elementAt(i);
      if (s != null) {
        TokenSymbol ts = grammar.tokenManager.getTokenSymbol(s);
        if (ts != null && ts.getASTNodeType() != null) {
          n++;
          if ( !generatedNewHashtable ) {
View Full Code Here

        // because they are all constants.
        println("public interface " + tm.getName() + TokenTypesFileSuffix + " {");
        tabs++;

        // Generate a definition for each token type
        Vector v = tm.getVocabulary();

        // Do special tokens manually
        println("int EOF = " + Token.EOF_TYPE + ";");
        println("int NULL_TREE_LOOKAHEAD = " + Token.NULL_TREE_LOOKAHEAD + ";");

        for (int i = Token.MIN_USER_TYPE; i < v.size(); i++) {
            String s = (String)v.elementAt(i);
            if (s != null) {
                if (s.startsWith("\"")) {
                    // a string literal
                    StringLiteralSymbol sl = (StringLiteralSymbol)tm.getTokenSymbol(s);
                    if (sl == null) {
View Full Code Here

            }
            else {
                if (r.access.equals("public")) {
          Alternative alt = new Alternative(); // create alt we'll add to ref rule
          RuleBlock targetRuleBlock = r.getBlock();
          Vector targetRuleAlts = targetRuleBlock.getAlternatives();
          // collect a sem pred if only one alt and it's at the start;
          // simple, but faster to implement until real hoisting
          if ( targetRuleAlts!=null && targetRuleAlts.size()==1 ) {
            Alternative onlyAlt = (Alternative)targetRuleAlts.elementAt(0);
            if ( onlyAlt.semPred!=null ) {
              // ok, has sem pred, make this rule ref alt have a pred
              alt.semPred = onlyAlt.semPred;
              // REMOVE predicate from target rule???  NOPE, another
              // rule other than nextToken() might invoke it.
View Full Code Here

     *  of the elements.
     */
    public static Vector parseSeparatedList(String list, char separator) {
        java.util.StringTokenizer st =
    new java.util.StringTokenizer(list, String.valueOf(separator));
        Vector v = new Vector(10);
        while ( st.hasMoreTokens() ) {
             v.appendElement(st.nextToken());
        }
        if (v.size() == 0) return null;
        return v;
    }
View Full Code Here

    protected Vector handlers;


    public ExceptionSpec(Token label_) {
        label = label_;
        handlers = new Vector();
    }
View Full Code Here

        println("token identifiers.  Some tokens are literals, and because of that");
        println("they have no identifiers.  Literals are double-quoted.");
        tabs++;

        // Enumerate all the valid token types
        Vector v = tm.getVocabulary();
        for (int i = Token.MIN_USER_TYPE; i < v.size(); i++) {
            String s = (String)v.elementAt(i);
            if (s != null) {
                println(s + " = " + i);
            }
        }
View Full Code Here

    /** Construct a named rule. */
    public RuleBlock(Grammar g, String r) {
        super(g);
        ruleName = r;
        labeledElements = new Vector();
        cache = new Lookahead[g.maxk + 1];
        exceptionSpecs = new Hashtable();
        setAutoGen(g instanceof ParserGrammar);
    }
View Full Code Here

TOP

Related Classes of org.jostraca.comp.antlr.collections.impl.Vector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.