Package net.sf.laja.parser.engine2

Examples of net.sf.laja.parser.engine2.Recorder


    return list.iterator().hasNext();
  }

  public boolean parse(int level, Source source, boolean parentNot, boolean caseSensitive, boolean receive) {
    level++;
    Recorder recorder = source.getRecorder();
    int bestMatchIdx = source.getBestIndex();
    int startBookmark = source.getBookmark();
    int startIndex = recorder.getIndex();
   
    for (Iterator i = list.iterator(); i.hasNext();) {
      ElementOutput elementOutput = (ElementOutput)i.next();
      Element element = elementOutput.getElement();
      Output output = elementOutput.getOutput();
      boolean elementNot = elementOutput.isNot();

      if (this.caseSensitive != null) {
        caseSensitive = this.caseSensitive.booleanValue();
      }
      if (elementOutput.isCaseSensitive() != null) {
        caseSensitive = elementOutput.isCaseSensitive().booleanValue();
      }

      int bookmark = source.getBookmark();

      boolean match = false;
      if (output.receive()) {
        if (receive) {
          match = recorder.playMatch(element, source.getBookmark());
          source.setBookmark(recorder.playBookmark());
        } else {
          output.init(source);
          int mindex = recorder.reserveMatchIndex(level, element, source.getBookmark(), parentNot, elementNot);
          int bindex = recorder.reserveBookmarkIndex();
          match = element.parse(level, source, not|parentNot|elementNot, caseSensitive, false);
          match = match != elementNot;
          recorder.set(level, source, element, bookmark, source.getBookmark(), source.getBestIndex(), mindex, bindex, match, parentNot, elementNot);
          output.set(source, bookmark);
        }
      } else {
        if (receive) {
          match = recorder.playMatch(element, source.getBookmark());
        } else {
          int mindex = recorder.reserveMatchIndex(level, element, source.getBookmark(), parentNot, elementNot);
          match = element.parse(level, source, not|parentNot|elementNot, caseSensitive, false);
          match = match != elementNot;
          recorder.set(level, source, element, bookmark, source.getBookmark(), source.getBestIndex(), mindex, match, parentNot, elementNot);
        }
      }
     
      if (match == not) {
        if (!receive) {
          recorder.setIndex(startIndex);
        }
        return false;
      }
     
      if (not) {
View Full Code Here


  public void add(int id, Element element, int flags, Output output) {
    elementList.add(id, element, flags, output);
  }

  public boolean parse(int level, Source source, boolean parentNot, boolean caseSensitive, boolean receive) {
    Recorder recorder = source.getRecorder();
    int bookmark = source.getBookmark();

    boolean match;

    if (receive) {
      match = recorder.playMatch(elementList, source.getBookmark());
    } else {
      int index = recorder.reserveMatchIndex(level, elementList, source.getBookmark(), parentNot, false);
      match = elementList.parse(level, source, parentNot, caseSensitive, false);
      recorder.set(level, source, elementList, bookmark, source.getBookmark(), source.getBestIndex(), index, match, parentNot, false);
    }
   
    if (!match) {
      source.setBookmark(bookmark);
    }
View Full Code Here

   *
   * @param context
   * @return
   */
  private static GeneratorResult execute(String grammarFile, final boolean forwardRef) {
    final Writer writer = new PrintWriter();
   
    // TODO: Fix this!
    ParsingSettings parsingSettings = new ParsingSettings() {
      @Override
      public boolean isForwardRef() {
        return forwardRef;
      }
    };
    grammarFile = Util.replaceSlash(grammarFile);
   
    writer.writeln("  Reading grammar \"" + grammarFile + "\"");
   
    GrammarParser parser = new GrammarParser(new IGrammarFactoryFactory() {
      public IGrammarFactory getFactory(int phase) {
        return new ParserFactory(writer);
      }}
View Full Code Here

        conditionElement.add(468, conditionElement_1);
        conditionElement.add(469, s);
        OrList conditionElement_2 = new OrList(470, "conditionElement_2");
        conditionElement_2.add(471, comparition, conditionElementConditionElementComparition);
        ElementList conditionElement_2_1 = new ElementList(472, "conditionElement_2_1");
        AndList conditionElement_2_1_1 = new AndList(473, "conditionElement_2_1_1");
        conditionElement_2_1_1.mainAnd(474, reference, conditionElementConditionElementReference);
        ElementList conditionElement_2_1_1_1 = new ElementList(475, "conditionElement_2_1_1_1");
        conditionElement_2_1_1_1.add(476, booleanData, NOT, conditionElementConditionElementBooleanData);
        conditionElement_2_1_1_1.add(478, new Complete(477, "conditionElement_2_1_1_1"));
        conditionElement_2_1_1.and(479, conditionElement_2_1_1_1);
        conditionElement_2_1.add(480, conditionElement_2_1_1);
        conditionElement_2.add(481, conditionElement_2_1);
        conditionElement_2.add(482, booleanData, conditionElementConditionElementBooleanCondition);
        conditionElement.add(483, conditionElement_2);
View Full Code Here

        conditionElement.add(468, conditionElement_1);
        conditionElement.add(469, s);
        OrList conditionElement_2 = new OrList(470, "conditionElement_2");
        conditionElement_2.add(471, comparition);
        ElementList conditionElement_2_1 = new ElementList(472, "conditionElement_2_1");
        AndList conditionElement_2_1_1 = new AndList(473, "conditionElement_2_1_1");
        conditionElement_2_1_1.mainAnd(474, reference);
        ElementList conditionElement_2_1_1_1 = new ElementList(475, "conditionElement_2_1_1_1");
        conditionElement_2_1_1_1.add(476, booleanData, NOT);
        conditionElement_2_1_1_1.add(478, new Complete(477, "conditionElement_2_1_1_1"));
        conditionElement_2_1_1.and(479, conditionElement_2_1_1_1);
        conditionElement_2_1.add(480, conditionElement_2_1_1);
        conditionElement_2.add(481, conditionElement_2_1);
        conditionElement_2.add(482, booleanData);
        conditionElement.add(483, conditionElement_2);
View Full Code Here

        Optional behaviour_4_1_2 = new Optional(277, "behaviour_4_1_2");
        behaviour_4_1_2.add(278, behaviourMethod);
        behaviour_4_1.add(279, behaviour_4_1_2);
        behaviour_4.add(280, behaviour_4_1);
        behaviour.add(281, behaviour_4);
        behaviour.add(283, new Complete(282, "behaviour"));

        return new TopElement(data2, behaviour);
    }
View Full Code Here

        Optional behaviour_4_1_2 = new Optional(277, "behaviour_4_1_2");
        behaviour_4_1_2.add(278, behaviourMethod);
        behaviour_4_1.add(279, behaviour_4_1_2);
        behaviour_4.add(280, behaviour_4_1);
        behaviour.add(281, behaviour_4);
        behaviour.add(283, new Complete(282, "behaviour"));

        return new TopElement(data1, behaviour);
    }
View Full Code Here

        constructor_1.add(13, constructorComment);
        constructor.add(14, constructor_1);
        OrList constructor_2 = new OrList(15, "constructor_2");
        ElementList constructor_2_1 = new ElementList(16, "constructor_2_1");
        constructor_2_1.add(17, constructorCodeBlock);
        constructor_2_1.add(19, new Complete(18, "constructor_2_1", constructorConstructorLastPart));
        constructor_2.add(20, constructor_2_1);
        ElementList constructor_2_2 = new ElementList(21, "constructor_2_2", constructorConstructorLastPart);
        constructor_2_2.add(23, new Marker(22, "endCodeBlock"));
        constructor_2_2.add(25, new Complete(24, "constructor_2_2"));
        constructor_2.add(26, constructor_2_2);
        constructor.add(27, constructor_2);

        return new TopElement(data2, constructor);
    }
View Full Code Here

        constructor_1.add(13, constructorComment);
        constructor.add(14, constructor_1);
        OrList constructor_2 = new OrList(15, "constructor_2");
        ElementList constructor_2_1 = new ElementList(16, "constructor_2_1");
        constructor_2_1.add(17, constructorCodeBlock);
        constructor_2_1.add(19, new Complete(18, "constructor_2_1"));
        constructor_2.add(20, constructor_2_1);
        ElementList constructor_2_2 = new ElementList(21, "constructor_2_2");
        constructor_2_2.add(23, new Marker(22, "endCodeBlock"));
        constructor_2_2.add(25, new Complete(24, "constructor_2_2"));
        constructor_2.add(26, constructor_2_2);
        constructor.add(27, constructor_2);

        return new TopElement(data1, constructor);
    }
View Full Code Here

        ElementList conditionElement_2_1 = new ElementList(472, "conditionElement_2_1");
        AndList conditionElement_2_1_1 = new AndList(473, "conditionElement_2_1_1");
        conditionElement_2_1_1.mainAnd(474, reference, conditionElementConditionElementReference);
        ElementList conditionElement_2_1_1_1 = new ElementList(475, "conditionElement_2_1_1_1");
        conditionElement_2_1_1_1.add(476, booleanData, NOT, conditionElementConditionElementBooleanData);
        conditionElement_2_1_1_1.add(478, new Complete(477, "conditionElement_2_1_1_1"));
        conditionElement_2_1_1.and(479, conditionElement_2_1_1_1);
        conditionElement_2_1.add(480, conditionElement_2_1_1);
        conditionElement_2.add(481, conditionElement_2_1);
        conditionElement_2.add(482, booleanData, conditionElementConditionElementBooleanCondition);
        conditionElement.add(483, conditionElement_2);
View Full Code Here

TOP

Related Classes of net.sf.laja.parser.engine2.Recorder

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.