Examples of metricsGrammarLexer


Examples of org.woped.metrics.formalGrammar.metricsGrammarLexer

  public static double interpretString(String formula, MetricsCalculator mc,
      HashSet<String> stack, boolean doNotDisplay, boolean syntaxCheck)
      throws CalculateFormulaException {
    try {
      CharStream stream = new ANTLRStringStream(formula);
      metricsGrammarLexer lexer = new metricsGrammarLexer(stream);
      TokenStream tokenStream = new CommonTokenStream(lexer);
      metricsGrammarParser parser = new metricsGrammarParser(tokenStream,
          mc, stack, doNotDisplay, syntaxCheck);
      return parser.evaluator();
    } catch (RecognitionException re) {
View Full Code Here

Examples of org.woped.metrics.formalGrammar.metricsGrammarLexer

      boolean doNotDisplay, boolean syntaxCheck) throws CalculateFormulaException {
    // Try if the Problem could be solved by checking if the usage of
    // the math framework is correct
    formula = mathToLowerCase(formula);
    CharStream stream = new ANTLRStringStream(formula);
    metricsGrammarLexer lexer = new metricsGrammarLexer(stream);
    TokenStream tokenStream = new CommonTokenStream(lexer);
    metricsGrammarParser parser = new metricsGrammarParser(tokenStream, mc,
        stack, doNotDisplay, syntaxCheck);
    try {
      double value = parser.evaluator();
View Full Code Here

Examples of org.woped.metrics.formalGrammar.metricsGrammarLexer

    // the parser interpret this as a variable
    // Try if the Problem could be solved by checking if the usage of
    // the math framework is correct
    formula = mathToLowerCase(formula);
    CharStream stream = new ANTLRStringStream(formula);
    metricsGrammarLexer lexer = new metricsGrammarLexer(stream);
    TokenStream tokenStream = new CommonTokenStream(lexer);
    metricsGrammarParser parser = new metricsGrammarParser(tokenStream, mc,
        stack, doNotDisplay, syntaxCheck);
    try {
      double value = parser.evaluator();
View Full Code Here

Examples of org.woped.metrics.formalGrammar.metricsGrammarLexer

        variablelist.put(variable.toLowerCase(), variable);
      }
     
    }   
    CharStream stream = new ANTLRStringStream(formula);
    metricsGrammarLexer lexer = new metricsGrammarLexer(stream);
    TokenStream tokenStream = new CommonTokenStream(lexer);
    metricsGrammarParser parser = new metricsGrammarParser(tokenStream, mc,
        stack, doNotDisplay, syntaxCheck);
    try {
      parser.evaluator();
View Full Code Here

Examples of org.woped.metrics.formalGrammar.metricsGrammarLexer

      throws CalculateFormulaException {
    String originalFormula = formula;
    int maxTries = 10;
    // Get actual Errors
    CharStream stream = new ANTLRStringStream(formula);
    metricsGrammarLexer lexer = new metricsGrammarLexer(stream);
    TokenStream tokenStream = new CommonTokenStream(lexer);
    metricsGrammarParser parser = new metricsGrammarParser(tokenStream, mc,
        stack, doNotDisplay, syntaxCheck);
    try {
      parser.evaluator();
    } catch (NestedCalculateFormulaException ncfe) {

      ArrayList<MismatchedTokenException> oldList = ncfe
          .getMismatchedTokenExceptions();
      ArrayList<String> missingChar = new ArrayList<String>();
      int numberOfItemsStart;
      int numberOfItemsEnd;

      do {
        maxTries--;
        numberOfItemsStart = missingChar.size();

        for (MismatchedTokenException mmte : oldList) {
          if (mmte.c == Token.EOF) {
            try {
              if (AntlrException.getTokenList()[mmte.expecting]
                  .equals("')'")) {
                formula = formula + ")";
                missingChar.add(")");
              }
            } catch (ArrayIndexOutOfBoundsException aioob) {

            }
          }
        }

        CharStream stream2 = new ANTLRStringStream(formula);
        metricsGrammarLexer lexer2 = new metricsGrammarLexer(stream2);
        TokenStream tokenStream2 = new CommonTokenStream(lexer2);
        metricsGrammarParser parser2 = new metricsGrammarParser(
            tokenStream2, mc, stack, doNotDisplay, syntaxCheck);
        try {
          parser2.evaluator();
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.