Package statechum.analysis.learning.rpnicore.LTL_to_ba

Examples of statechum.analysis.learning.rpnicore.LTL_to_ba.Lexer


  public static final int erlDot = 21;
  public static final int erlE = 22;
  public static final int erlText = 23;

  public static Lexer buildLexer(String whatToParse) {
    return new Lexer("(\\s*\\{\\s*)|" + // erlTupleBegin
        "(\\s*}\\s*)|" + // erlTupleEnd
        "(\\s*\\[\\s*)|" + // erlListBegin
        "(\\s*]\\s*)|" + // erlListEnd
        "(\\s*<<\\s*)|" + // erlBitStrBegin
        "(\\s*>>\\s*)|" + // erlBitStrEnd
View Full Code Here


   * @param str
   *            text to parse
   * @return the outcome.
   */
  public static OtpErlangObject parseText(String str) {
    Lexer lexer = buildLexer(str);
    OtpErlangObject result = parseFirstTermInText(lexer);
    if (lexer.getLastMatchType() >= 0)// did not get to the end of string
      throw new IllegalArgumentException(
          "unexpected characters at the end of string to parse, looking at "
              + lexer.remaining());
    return result;
  }
View Full Code Here

  public static final int erlDot = 21;
  public static final int erlE = 22;
  public static final int erlText = 23;

  public static Lexer buildLexer(String whatToParse) {
    return new Lexer("(\\s*\\{\\s*)|" + // erlTupleBegin
        "(\\s*}\\s*)|" + // erlTupleEnd
        "(\\s*\\[\\s*)|" + // erlListBegin
        "(\\s*]\\s*)|" + // erlListEnd
        "(\\s*<<\\s*)|" + // erlBitStrBegin
        "(\\s*>>\\s*)|" + // erlBitStrEnd
View Full Code Here

   * @param str
   *            text to parse
   * @return the outcome.
   */
  public static OtpErlangObject parseText(String str) {
    Lexer lexer = buildLexer(str);
    OtpErlangObject result = parseFirstTermInText(lexer);
    if (lexer.getLastMatchType() >= 0)// did not get to the end of string
      throw new IllegalArgumentException(
          "unexpected characters at the end of string to parse, looking at "
              + lexer.remaining());
    return result;
  }
View Full Code Here

  /** Junk at the end of term which can be retrieved. */
  @Test
  public void testParse0c()
  {
    final String text = "\'this is an atom\' junk and more";
      Lexer lexer = ErlangLabel.buildLexer(text);
      OtpErlangObject result = ErlangLabel.parseFirstTermInText(lexer);
    OtpErlangAtom atom = (OtpErlangAtom)result;
    Assert.assertEquals("\'this is an atom\'",ErlangLabel.dumpErlangObject(atom));
    Assert.assertEquals("junk and more",lexer.remaining());
  }
View Full Code Here

          // Match lists of traces
          line = line.trim();
          if (line.startsWith("[")) {
            // strip the start and end brackets
            line = line.substring(1, line.length() - 1).trim();
            Lexer lexer = ErlangLabel.buildLexer(line);
            int match = lexer.getMatchType();

            try {
              while (match > 0) {
                String s = ErlangLabel.parseFirstTermInText(
                    lexer).toString();
                addAlphabetElements(s);
                match = lexer.getLastMatchType();
              }
            } catch (IllegalArgumentException e) {
              // we are done...
            }
          }
View Full Code Here

      public void addTrace(List<Label> trace, boolean positive);
    }
   
    public static void parseSequenceOfTraces(String traces,Configuration config,TraceAdder collector)
    {
      Lexer lexer = ErlangLabel.buildLexer(traces);
      int match = lexer.getMatchType();
     
    while(match > 0)
    {
      Boolean positiveNegative = null;
        if (match == ErlangLabel.erlPlus)
          positiveNegative = true;
        else
          if (match == ErlangLabel.erlMinus)
            positiveNegative = false;
          else
            if (match != ErlangLabel.erlComma && lexer.getLastMatchType() != ErlangLabel.erlSpaces)
              throw new IllegalArgumentException("a collection of traces should start with either "+cmdPositive+" or "+cmdNegative+", got"+lexer.getMatch()+" in "+lexer.remaining());
        if (positiveNegative != null)
        {
          for(List<Label> sequence:StatechumXML.readSequenceList(ErlangLabel.parseFirstTermInText(lexer),config))
            collector.addTrace(sequence, positiveNegative.booleanValue());
          match = lexer.getLastMatchType();
        }
        else match = lexer.getMatchType();
    }
    }
View Full Code Here

      public void addTrace(List<Label> trace, boolean positive);
    }
   
    public static void parseSequenceOfTraces(String traces,Configuration config,TraceAdder collector)
    {
      Lexer lexer = ErlangLabel.buildLexer(traces);
      int match = lexer.getMatchType();
     
    while(match > 0)
    {
      Boolean positiveNegative = null;
        if (match == ErlangLabel.erlPlus)
          positiveNegative = true;
        else
          if (match == ErlangLabel.erlMinus)
            positiveNegative = false;
          else
            if (match != ErlangLabel.erlComma && lexer.getLastMatchType() != ErlangLabel.erlSpaces)
              throw new IllegalArgumentException("a collection of traces should start with either "+cmdPositive+" or "+cmdNegative+", got"+lexer.getMatch()+" in "+lexer.remaining());
        if (positiveNegative != null)
        {
          for(List<Label> sequence:StatechumXML.readSequenceList(ErlangLabel.parseFirstTermInText(lexer),config,null))
            collector.addTrace(sequence, positiveNegative.booleanValue());
          match = lexer.getLastMatchType();
        }
        else match = lexer.getMatchType();
    }
    }
View Full Code Here

  public static final int erlDot = 21;
  public static final int erlE = 22;
  public static final int erlText = 23;

  public static Lexer buildLexer(String whatToParse) {
    return new Lexer("(\\s*\\{\\s*)|" + // erlTupleBegin
        "(\\s*}\\s*)|" + // erlTupleEnd
        "(\\s*\\[\\s*)|" + // erlListBegin
        "(\\s*]\\s*)|" + // erlListEnd
        "(\\s*<<\\s*)|" + // erlBitStrBegin
        "(\\s*>>\\s*)|" + // erlBitStrEnd
View Full Code Here

   * @param str
   *            text to parse
   * @return the outcome.
   */
  public static OtpErlangObject parseText(String str) {
    Lexer lexer = buildLexer(str);
    OtpErlangObject result = parseFirstTermInText(lexer);
    if (lexer.getLastMatchType() >= 0)// did not get to the end of string
      throw new IllegalArgumentException(
          "unexpected characters at the end of string to parse, looking at "
              + lexer.remaining());
    return result;
  }
View Full Code Here

TOP

Related Classes of statechum.analysis.learning.rpnicore.LTL_to_ba.Lexer

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.