Examples of Grammar


Examples of mf.org.apache.xerces.xni.grammars.Grammar

    public void cacheGrammars(String grammarType, Grammar[] grammars) {
        if(!fPoolIsLocked) {
            for (int i = 0; i < grammars.length; i++) {
                if(DEBUG) {
                    System.out.println("CACHED GRAMMAR " + (i+1) ) ;
                    Grammar temp = grammars[i] ;
                    //print(temp.getGrammarDescription());
                }
                putGrammar(grammars[i]);
            }
        }
View Full Code Here

Examples of mf.org.apache.xerces.xni.grammars.Grammar

                        prev.next = entry.next;
            }
            else {
                fGrammars[index] = entry.next;
            }
                Grammar tempGrammar = entry.grammar;
                entry.grammar = null;
                fGrammarCount--;
                return tempGrammar;
            }
        }
View Full Code Here

Examples of net.percederberg.grammatica.Grammar

     * Writes the source code files.
     *
     * @throws IOException if the files couldn't be written correctly
     */
    public void write() throws IOException {
        Grammar                   grammar = getGrammar();
        VisualBasicConstantsFile  constants;
        VisualBasicTokenizerFile  tokenizer;
        VisualBasicParserFile     parser;
        VisualBasicAnalyzerFile   analyzer;
        TokenPattern              token;
        ProductionPattern         production;
        int                       i;

        // Create output files
        constants = new VisualBasicConstantsFile(this);
        tokenizer = new VisualBasicTokenizerFile(this);
        analyzer = new VisualBasicAnalyzerFile(this);
        parser = new VisualBasicParserFile(this, tokenizer, analyzer);

        // Create token declarations
        for (i = 0; i < grammar.getTokenPatternCount(); i++) {
            token = grammar.getTokenPattern(i);
            constants.addToken(token);
            tokenizer.addToken(token, constants);
            analyzer.addToken(token, constants);
        }

        // Create production constants
        for (i = 0; i < grammar.getProductionPatternCount(); i++) {
            production = grammar.getProductionPattern(i);
            constants.addProduction(production);
            parser.addProductionConstant(production);
            analyzer.addProduction(production, constants);
        }

        // Create production declarations
        for (i = 0; i < grammar.getProductionPatternCount(); i++) {
            production = grammar.getProductionPattern(i);
            parser.addProduction(production, constants);
        }

        // Write source code files
        constants.writeCode();
View Full Code Here

Examples of net.sf.laja.parser.grammar.element.Grammar

    );
 
    ParsingResult result = parser.parseFile(grammarFile);

    if (result.success()) {
      Grammar grammar = ((ParserFactory)parser.getFactory()).getGrammar();
      return grammar.getGeneratorResult(parsingSettings);
    }
    throw new ParserException("Could not generate grammar: " + result);
  }
View Full Code Here

Examples of net.sf.lapg.api.Grammar

      InputStream is = openInput(notifier);
      if (is == null) {
        return false;
      }

      Grammar s = SyntaxUtil.parseSyntax(options.getInput(), is, notifier, getDefaultOptions());
      if (s == null || s.hasErrors()) {
        return false;
      }

      Map<String, Object> genOptions = new HashMap<String, Object>(s.getOptions());
      Map<String, Object> additional = options.getAdditionalOptions();
      for (String key : additional.keySet()) {
        genOptions.put(key, additional.get(key));
      }

      long start = System.currentTimeMillis();
      ProcessingStatusAdapter adapter = new ProcessingStatusAdapter(notifier, options.getDebug());
      LexerTables l = LexicalBuilder.compile(s.getLexems(), adapter);
      ParserTables r = Builder.compile(s, adapter);
      if(l == null || r == null) {
        return false;
      }
      long generationTime = System.currentTimeMillis() - start;

      HashMap<String, Object> map = new HashMap<String, Object>();
      map.put("syntax", s);
      map.put("lex", l);
      map.put("parser", r);
      map.put("opts", genOptions);

      start = System.currentTimeMillis();
      generateOutput(map, s.getTemplates(), notifier);
      long textTime = System.currentTimeMillis() - start;
      notifier.info("lalr: " + generationTime/1000. + "s, text: " + textTime/1000. + "s\n");
      return true;
    } catch (Throwable t) {
      notifier.error("lapg: internal error: " + t.getClass().getName() + "\n");
View Full Code Here

Examples of net.sourceforge.chaperon.grammar.Grammar

    try
    {

      if (localName.equals(GRAMMAR_ELEMENT))
      {
        grammar = new Grammar();
        grammar.setURI(atts.getValue(URI_ATTRIBUTE));
        stack.push(grammar);
      }
      else if (localName.equals(TOKENLIST_ELEMENT))
      {
View Full Code Here

Examples of net.sourceforge.chaperon.model.grammar.Grammar

    // Create a grammar model for a given grammar file
    GrammarFactory grammarfactory = new GrammarFactory();
    xmlparser.setContentHandler(grammarfactory);
    xmlparser.parse(grammarFile.toString());

    Grammar grammar = grammarfactory.getGrammar();

    // Build a automaton from the grammar model
    ParserAutomaton parserautomaton =
      (new ParserAutomatonBuilder(grammar, log)).getParserAutomaton();
View Full Code Here

Examples of net.sourceforge.chaperon.model.grammar.Grammar

    E = new Nonterminal("E");
    T = new Nonterminal("T");
    F = new Nonterminal("F");

    grammar = new Grammar();

    // E -> E + T
    Production production = new Production(E);
    production.getDefinition().addSymbol(E);
    production.getDefinition().addSymbol(plus);
View Full Code Here

Examples of net.sourceforge.chaperon.model.grammar.Grammar

    GrammarFactory handler = new GrammarFactory();
    parser.setContentHandler(handler);
    parser.parse(new InputSource(getClass().getResourceAsStream("java.xgrm")));

    Grammar grammar = handler.getGrammar();

    Automaton collection = new Automaton(grammar,  /*firstsets,*/
                                         null);

    System.out.println(collection);
View Full Code Here

Examples of net.sourceforge.chaperon.model.grammar.Grammar

    Eprime = new Nonterminal("E'");
    T = new Nonterminal("T");
    Tprime = new Nonterminal("T'");
    F = new Nonterminal("F");

    grammar = new Grammar();

    grammar.setStartSymbol(E);

    // E -> T E'
    Production production = new Production(E);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.