Ejemplo n.º 1
0
 /**
  * Attempt to recover from a single missing or extra token.
  *
  * <p>EXTRA TOKEN
  *
  * <p>LA(1) is not what we are looking for. If LA(2) has the right token, however, then assume
  * LA(1) is some extra spurious token. Delete it and LA(2) as if we were doing a normal match(),
  * which advances the input.
  *
  * <p>MISSING TOKEN
  *
  * <p>If current token is consistent with what could come after ttype then it is ok to "insert"
  * the missing token, else throw exception For example, Input "i=(3;" is clearly missing the ')'.
  * When the parser returns from the nested call to expr, it will have call chain:
  *
  * <p>stat &rarr; expr &rarr; atom
  *
  * <p>and it will be trying to match the ')' at this point in the derivation:
  *
  * <p>=&gt; ID '=' '(' INT ')' ('+' atom)* ';' ^ match() will see that ';' doesn't match ')' and
  * report a mismatched token error. To recover, it sees that LA(1)==';' is in the set of tokens
  * that can follow the ')' token reference in rule atom. It can assume that you forgot the ')'.
  */
 protected Object recoverFromMismatchedToken(IntStream input, int ttype, BitSet follow)
     throws RecognitionException {
   RecognitionException e = null;
   // if next token is what we are looking for then "delete" this token
   if (mismatchIsUnwantedToken(input, ttype)) {
     e = new UnwantedTokenException(ttype, input);
     /*
     System.err.println("recoverFromMismatchedToken deleting "+
     				   ((TokenStream)input).LT(1)+
     				   " since "+((TokenStream)input).LT(2)+" is what we want");
      */
     beginResync();
     input.consume(); // simply delete extra token
     endResync();
     reportError(e); // report after consuming so AW sees the token in the exception
     // we want to return the token we're actually matching
     Object matchedSymbol = getCurrentInputSymbol(input);
     input.consume(); // move past ttype token as if all were ok
     return matchedSymbol;
   }
   // can't recover with single token deletion, try insertion
   if (mismatchIsMissingToken(input, follow)) {
     Object inserted = getMissingSymbol(input, e, ttype, follow);
     e = new MissingTokenException(ttype, input, inserted);
     reportError(e); // report after inserting so AW sees the token in the exception
     return inserted;
   }
   // even that didn't work; must throw the exception
   e = new MismatchedTokenException(ttype, input);
   throw e;
 }
Ejemplo n.º 2
0
 public void consumeUntil(IntStream input, int tokenType) {
   // System.out.println("consumeUntil "+tokenType);
   int ttype = input.LA(1);
   while (ttype != Token.EOF && ttype != tokenType) {
     input.consume();
     ttype = input.LA(1);
   }
 }
Ejemplo n.º 3
0
 /** Consume tokens until one matches the given token set */
 public void consumeUntil(IntStream input, BitSet set) {
   // System.out.println("consumeUntil("+set.toString(getTokenNames())+")");
   int ttype = input.LA(1);
   while (ttype != Token.EOF && !set.member(ttype)) {
     // System.out.println("consume during recover LA(1)="+getTokenNames()[input.LA(1)]);
     input.consume();
     ttype = input.LA(1);
   }
 }
Ejemplo n.º 4
0
  public static void main(String... args) {

    /*
    -------------------------------------------------------------------------
    From obj to ...
    -------------------------------------------------------------------------
    */
    Stream<String> streamOfStrings = Stream.of("un", "deux", "trois");
    Function<String, StringBuilder> function = StringBuilder::new;
    streamOfStrings.map(function) /*.forEach(System.out::println)*/;
    streamOfStrings = Stream.of("un", "deux", "trois");
    ToIntFunction<String> toIntFunction = String::length;
    IntStream streamOfInts = streamOfStrings.mapToInt(toIntFunction);
    streamOfStrings = Stream.of("un", "deux", "trois");
    ToDoubleFunction<String> toDoubleFunction = String::length;
    DoubleStream streamOfDoubles = streamOfStrings.mapToDouble(toDoubleFunction);
    streamOfStrings = Stream.of("un", "deux", "trois");
    ToLongFunction<String> toLongFunction = String::length;
    LongStream streamOfLongs = streamOfStrings.mapToLong(toLongFunction);

    /*
    -------------------------------------------------------------------------
    From int to ...
    -------------------------------------------------------------------------
    */
    IntUnaryOperator plusplus = i -> i++;
    IntStream.of(1, 2, 3).map(plusplus)
    /*.forEach(x->System.out.println(x))*/ ;
    IntFunction<String> intFunction = i -> "" + i;
    IntStream.of(1, 2, 3).mapToObj(intFunction)
    /*.forEach(System.out::println)*/ ;
    IntToDoubleFunction itdf = i -> i;
    IntStream.of(1, 2, 3).mapToDouble(itdf)
    /*.forEach(System.out::println)*/ ;
    IntToLongFunction itlf = i -> i;
    IntStream.of(1, 2, 3).mapToLong(itlf)
    /*.forEach(System.out::println)*/ ;

    /*
    -------------------------------------------------------------------------
    From long to ...
    -------------------------------------------------------------------------
    */
    LongUnaryOperator times = l -> l * l;
    LongStream.of(1L, 2L, 3L).map(times)
    /*.forEach(System.out::println)*/ ;
    LongFunction<String> lf = l -> "toto";
    LongStream.of(1L, 2L, 3L).mapToObj(lf);

    /*
    -------------------------------------------------------------------------
    From double to ...
    -------------------------------------------------------------------------
    */
    DoubleToIntFunction dtif = d -> (int) d;
    DoubleStream.of(1.3, 1.5, 1.6).mapToInt(dtif).forEach(System.out::println);
  }
    public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
      IntStream input = _input;
      int _s = s;
      switch (s) {
        case 0:
          int LA6_0 = input.LA(1);

          s = -1;
          if ((LA6_0 == 'w')) {
            s = 1;
          } else if ((LA6_0 == 'h')) {
            s = 2;
          } else if ((LA6_0 == ';')) {
            s = 3;
          } else if ((LA6_0 == 'o')) {
            s = 4;
          } else if ((LA6_0 == '(')) {
            s = 5;
          } else if ((LA6_0 == ')')) {
            s = 6;
          } else if ((LA6_0 == 'c')) {
            s = 7;
          } else if ((LA6_0 == 'i')) {
            s = 8;
          } else if ((LA6_0 == 'd')) {
            s = 9;
          } else if ((LA6_0 == 'r')) {
            s = 10;
          } else if ((LA6_0 == '/')) {
            s = 11;
          } else if (((LA6_0 >= '\t' && LA6_0 <= '\n') || LA6_0 == '\r' || LA6_0 == ' ')) {
            s = 12;
          } else if (((LA6_0 >= '\u0000' && LA6_0 <= '\b')
              || (LA6_0 >= '\u000B' && LA6_0 <= '\f')
              || (LA6_0 >= '\u000E' && LA6_0 <= '\u001F')
              || (LA6_0 >= '!' && LA6_0 <= '\'')
              || (LA6_0 >= '*' && LA6_0 <= '.')
              || (LA6_0 >= '0' && LA6_0 <= ':')
              || (LA6_0 >= '<' && LA6_0 <= 'b')
              || (LA6_0 >= 'e' && LA6_0 <= 'g')
              || (LA6_0 >= 'j' && LA6_0 <= 'n')
              || (LA6_0 >= 'p' && LA6_0 <= 'q')
              || (LA6_0 >= 's' && LA6_0 <= 'v')
              || (LA6_0 >= 'x' && LA6_0 <= '\uFFFF'))) {
            s = 13;
          }

          if (s >= 0) return s;
          break;
      }
      NoViableAltException nvae = new NoViableAltException(getDescription(), 6, _s, input);
      error(nvae);
      throw nvae;
    }
Ejemplo n.º 6
0
 /**
  * Recover from an error found on the input stream. Mostly this is NoViableAlt exceptions, but
  * could be a mismatched token that the match() routine could not recover from.
  */
 public void recover(IntStream input, RecognitionException re) {
   if (lastErrorIndex == input.index()) {
     // uh oh, another error at same token index; must be a case
     // where LT(1) is in the recovery token set so nothing is
     // consumed; consume a single token so at least to prevent
     // an infinite loop; this is a failsafe.
     input.consume();
   }
   lastErrorIndex = input.index();
   BitSet followSet = computeErrorRecoverySet();
   beginResync();
   consumeUntil(input, followSet);
   endResync();
 }
Ejemplo n.º 7
0
  public List<List<Integer>> subsetsWithDup(int[] num) {
    Arrays.sort(num);

    return new ArrayList<>(
        IntStream.range(0, 1 << num.length)
            .mapToObj(
                mask ->
                    IntStream.range(0, num.length)
                        .filter(i -> ((1 << i) & mask) > 0)
                        .map(i -> num[i])
                        .boxed()
                        .collect(Collectors.toList()))
            .collect(Collectors.toSet()));
  }
Ejemplo n.º 8
0
 /**
  * Match current input symbol against ttype. Upon error, do one token insertion or deletion if
  * possible. You can override to not recover here and bail out of the current production to the
  * normal error exception catch (at the end of the method) by just throwing
  * MismatchedTokenException upon input.LA(1)!=ttype.
  */
 public void match(IntStream input, int ttype, BitSet follow) throws RecognitionException {
   if (input.LA(1) == ttype) {
     input.consume();
     errorRecovery = false;
     failed = false;
     return;
   }
   if (backtracking > 0) {
     failed = true;
     return;
   }
   mismatch(input, ttype, follow);
   return;
 }
Ejemplo n.º 9
0
 /**
  * Has this rule already parsed input at the current index in the input stream? Return the stop
  * token index or MEMO_RULE_UNKNOWN. If we attempted but failed to parse properly before, return
  * MEMO_RULE_FAILED.
  *
  * <p>This method has a side-effect: if we have seen this input for this rule and successfully
  * parsed before, then seek ahead to 1 past the stop token matched for this rule last time.
  */
 public boolean alreadyParsedRule(IntStream input, int ruleIndex) {
   int stopIndex = getRuleMemoization(ruleIndex, input.index());
   if (stopIndex == MEMO_RULE_UNKNOWN) {
     return false;
   }
   if (stopIndex == MEMO_RULE_FAILED) {
     // System.out.println("rule "+ruleIndex+" will never succeed");
     failed = true;
   } else {
     // System.out.println("seen rule "+ruleIndex+" before; skipping ahead to @"+(stopIndex+1)+"
     // failed="+failed);
     input.seek(stopIndex + 1); // jump to one past stop token
   }
   return true;
 }
Ejemplo n.º 10
0
  public boolean mismatchIsMissingToken(IntStream input, BitSet follow) {
    if (follow == null) {
      // we have no information about the follow; we can only consume
      // a single token and hope for the best
      return false;
    }
    // compute what can follow this grammar element reference
    if (follow.member(Token.EOR_TOKEN_TYPE)) {
      BitSet viableTokensFollowingThisRule = computeContextSensitiveRuleFOLLOW();
      follow = follow.or(viableTokensFollowingThisRule);
      if (state._fsp >= 0) { // remove EOR if we're not the start symbol
        follow.remove(Token.EOR_TOKEN_TYPE);
      }
    }
    // if current token is consistent with what could come after set
    // then we know we're missing a token; error recovery is free to
    // "insert" the missing token

    // System.out.println("viable tokens="+follow.toString(getTokenNames()));
    // System.out.println("LT(1)="+((TokenStream)input).LT(1));

    // BitSet cannot handle negative numbers like -1 (EOF) so I leave EOR
    // in follow set to indicate that the fall of the start symbol is
    // in the set (EOF can follow).
    if (follow.member(input.LA(1)) || follow.member(Token.EOR_TOKEN_TYPE)) {
      // System.out.println("LT(1)=="+((TokenStream)input).LT(1)+" is consistent with what follows;
      // inserting...");
      return true;
    }
    return false;
  }
Ejemplo n.º 11
0
 /**
  * Match current input symbol against ttype. Attempt single token insertion or deletion error
  * recovery. If that fails, throw MismatchedTokenException.
  *
  * <p>To turn off single token insertion or deletion error recovery, override
  * recoverFromMismatchedToken() and have it throw an exception. See
  * TreeParser.recoverFromMismatchedToken(). This way any error in a rule will cause an exception
  * and immediate exit from rule. Rule would recover by resynchronizing to the set of symbols that
  * can follow rule ref.
  */
 public Object match(IntStream input, int ttype, BitSet follow) throws RecognitionException {
   // System.out.println("match "+((TokenStream)input).LT(1));
   Object matchedSymbol = getCurrentInputSymbol(input);
   if (input.LA(1) == ttype) {
     input.consume();
     state.errorRecovery = false;
     state.failed = false;
     return matchedSymbol;
   }
   if (state.backtracking > 0) {
     state.failed = true;
     return matchedSymbol;
   }
   matchedSymbol = recoverFromMismatchedToken(input, ttype, follow);
   return matchedSymbol;
 }
Ejemplo n.º 12
0
 /**
  * This code is factored out from mismatched token and mismatched set recovery. It handles "single
  * token insertion" error recovery for both. No tokens are consumed to recover from insertions.
  * Return true if recovery was possible else return false.
  */
 protected boolean recoverFromMismatchedElement(
     IntStream input, RecognitionException e, BitSet follow) {
   if (follow == null) {
     // we have no information about the follow; we can only consume
     // a single token and hope for the best
     return false;
   }
   // System.out.println("recoverFromMismatchedElement");
   // compute what can follow this grammar element reference
   if (follow.member(Token.EOR_TOKEN_TYPE)) {
     BitSet viableTokensFollowingThisRule = computeContextSensitiveRuleFOLLOW();
     follow = follow.or(viableTokensFollowingThisRule);
     follow.remove(Token.EOR_TOKEN_TYPE);
   }
   // if current token is consistent with what could come after set
   // then it is ok to "insert" the missing token, else throw exception
   // System.out.println("viable tokens="+follow.toString(getTokenNames())+")");
   if (follow.member(input.LA(1))) {
     // System.out.println("LT(1)=="+input.LT(1)+" is consistent with what follows; inserting...");
     reportError(e);
     return true;
   }
   // System.err.println("nothing to do; throw exception");
   return false;
 }
Ejemplo n.º 13
0
    public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
      IntStream input = _input;
      int _s = s;
      switch (s) {
        case 0:
          int LA16_18 = input.LA(1);

          s = -1;
          if (((LA16_18 >= '\u0000' && LA16_18 <= '\uFFFF'))) {
            s = 58;
          } else s = 57;

          if (s >= 0) return s;
          break;
      }
      NoViableAltException nvae = new NoViableAltException(getDescription(), 16, _s, input);
      error(nvae);
      throw nvae;
    }
Ejemplo n.º 14
0
 /**
  * Attempt to recover from a single missing or extra token.
  *
  * <p>EXTRA TOKEN
  *
  * <p>LA(1) is not what we are looking for. If LA(2) has the right token, however, then assume
  * LA(1) is some extra spurious token. Delete it and LA(2) as if we were doing a normal match(),
  * which advances the input.
  *
  * <p>MISSING TOKEN
  *
  * <p>If current token is consistent with what could come after ttype then it is ok to "insert"
  * the missing token, else throw exception For example, Input "i=(3;" is clearly missing the ')'.
  * When the parser returns from the nested call to expr, it will have call chain:
  *
  * <p>stat -> expr -> atom
  *
  * <p>and it will be trying to match the ')' at this point in the derivation:
  *
  * <p>=> ID '=' '(' INT ')' ('+' atom)* ';' ^ match() will see that ';' doesn't match ')' and
  * report a mismatched token error. To recover, it sees that LA(1)==';' is in the set of tokens
  * that can follow the ')' token reference in rule atom. It can assume that you forgot the ')'.
  */
 public void recoverFromMismatchedToken(
     IntStream input, RecognitionException e, int ttype, BitSet follow)
     throws RecognitionException {
   // if next token is what we are looking for then "delete" this token
   if (input.LA(2) == ttype) {
     reportError(e);
     /*
      * System.err.println("recoverFromMismatchedToken deleting "+input.LT
      * (1)+ " since "+input.LT(2)+" is what we want");
      */
     beginResync();
     input.consume(); // simply delete extra token
     endResync();
     input.consume(); // move past ttype token as if all were ok
     return;
   }
   if (!recoverFromMismatchedElement(input, e, follow)) {
     throw e;
   }
 }
Ejemplo n.º 15
0
 /**
  * Record whether or not this rule parsed the input at this position successfully. Use a standard
  * java hashtable for now.
  */
 public void memoize(IntStream input, int ruleIndex, int ruleStartIndex) {
   int stopTokenIndex = state.failed ? MEMO_RULE_FAILED : input.index() - 1;
   if (state.ruleMemo == null) {
     System.err.println("!!!!!!!!! memo array is null for " + getGrammarFileName());
   }
   if (ruleIndex >= state.ruleMemo.length) {
     System.err.println(
         "!!!!!!!!! memo size is " + state.ruleMemo.length + ", but rule index is " + ruleIndex);
   }
   if (state.ruleMemo[ruleIndex] != null) {
     state.ruleMemo[ruleIndex].put(ruleStartIndex, stopTokenIndex);
   }
 }
  void fun() {

    IntStream.range(1, 5)
        .map((x) -> x * x)
        .map(
            x ->
                square(
                    x)) // Noncompliant [[sc=16;ec=18]] {{Replace this lambda with a method
                        // reference.}}
        .map(
            x -> { // Noncompliant
              return square(x);
            })
        .map(this::square) // Compliant
        .forEach(System.out::println);
    IntStream.range(1, 5).forEach(x -> System.out.println(x)); // Noncompliant
    IntStream.range(1, 5)
        .forEach(
            x -> { // Noncompliant
              System.out.println(x);
            });
    IntStream.range(1, 5)
        .forEach(
            x -> {
              return;
            }); // Compliant

    Arrays.asList("bar").stream().filter(string -> string.startsWith("b")); // Compliant
    Arrays.asList(new A()).stream().filter(a -> a.coolerThan(0, a)); // Compliant
    foo((x, y) -> x * y);
    foo(
        (x, y) -> {;
        });
    foo(
        (x, y) -> {;;
        });
  }
Ejemplo n.º 17
0
  public static void main(String... args) {

    List<Integer> numbers = Arrays.asList(3, 4, 5, 1, 2);

    Arrays.stream(numbers.toArray()).forEach(System.out::println);
    int calories = Dish.menu.stream().mapToInt(Dish::getCalories).sum();
    System.out.println("Number of calories:" + calories);

    // max and OptionalInt
    OptionalInt maxCalories = Dish.menu.stream().mapToInt(Dish::getCalories).max();

    int max;
    if (maxCalories.isPresent()) {
      max = maxCalories.getAsInt();
    } else {
      // we can choose a default value
      max = 1;
    }
    System.out.println(max);

    // numeric ranges
    IntStream evenNumbers = IntStream.rangeClosed(1, 100).filter(n -> n % 2 == 0);

    System.out.println(evenNumbers.count());

    Stream<int[]> pythagoreanTriples =
        IntStream.rangeClosed(1, 100)
            .boxed()
            .flatMap(
                a ->
                    IntStream.rangeClosed(a, 100)
                        .filter(b -> Math.sqrt(a * a + b * b) % 1 == 0)
                        .boxed()
                        .map(b -> new int[] {a, b, (int) Math.sqrt(a * a + b * b)}));

    pythagoreanTriples.forEach(t -> System.out.println(t[0] + ", " + t[1] + ", " + t[2]));
  }
    public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
      IntStream input = _input;
      int _s = s;
      switch (s) {
        case 0:
          int LA12_19 = input.LA(1);

          s = -1;
          if (((LA12_19 >= '\u0000' && LA12_19 <= '\uFFFF'))) {
            s = 48;
          } else s = 23;

          if (s >= 0) return s;
          break;
        case 1:
          int LA12_0 = input.LA(1);

          s = -1;
          if ((LA12_0 == '1')) {
            s = 1;
          } else if ((LA12_0 == 'a')) {
            s = 2;
          } else if ((LA12_0 == 'b')) {
            s = 3;
          } else if ((LA12_0 == '2')) {
            s = 4;
          } else if ((LA12_0 == 'c')) {
            s = 5;
          } else if ((LA12_0 == 'd')) {
            s = 6;
          } else if ((LA12_0 == '3')) {
            s = 7;
          } else if ((LA12_0 == '4')) {
            s = 8;
          } else if ((LA12_0 == '5')) {
            s = 9;
          } else if ((LA12_0 == '6')) {
            s = 10;
          } else if ((LA12_0 == '7')) {
            s = 11;
          } else if ((LA12_0 == '8')) {
            s = 12;
          } else if ((LA12_0 == '9')) {
            s = 13;
          } else if ((LA12_0 == 's')) {
            s = 14;
          } else if ((LA12_0 == 'n')) {
            s = 15;
          } else if ((LA12_0 == '^')) {
            s = 16;
          } else if (((LA12_0 >= 'A' && LA12_0 <= 'Z')
              || LA12_0 == '_'
              || (LA12_0 >= 'e' && LA12_0 <= 'm')
              || (LA12_0 >= 'o' && LA12_0 <= 'r')
              || (LA12_0 >= 't' && LA12_0 <= 'z'))) {
            s = 17;
          } else if ((LA12_0 == '0')) {
            s = 18;
          } else if ((LA12_0 == '\"')) {
            s = 19;
          } else if ((LA12_0 == '\'')) {
            s = 20;
          } else if ((LA12_0 == '/')) {
            s = 21;
          } else if (((LA12_0 >= '\t' && LA12_0 <= '\n') || LA12_0 == '\r' || LA12_0 == ' ')) {
            s = 22;
          } else if (((LA12_0 >= '\u0000' && LA12_0 <= '\b')
              || (LA12_0 >= '\u000B' && LA12_0 <= '\f')
              || (LA12_0 >= '\u000E' && LA12_0 <= '\u001F')
              || LA12_0 == '!'
              || (LA12_0 >= '#' && LA12_0 <= '&')
              || (LA12_0 >= '(' && LA12_0 <= '.')
              || (LA12_0 >= ':' && LA12_0 <= '@')
              || (LA12_0 >= '[' && LA12_0 <= ']')
              || LA12_0 == '`'
              || (LA12_0 >= '{' && LA12_0 <= '\uFFFF'))) {
            s = 23;
          }

          if (s >= 0) return s;
          break;
        case 2:
          int LA12_20 = input.LA(1);

          s = -1;
          if (((LA12_20 >= '\u0000' && LA12_20 <= '\uFFFF'))) {
            s = 48;
          } else s = 23;

          if (s >= 0) return s;
          break;
      }
      NoViableAltException nvae = new NoViableAltException(getDescription(), 12, _s, input);
      error(nvae);
      throw nvae;
    }
    public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
      IntStream input = _input;
      int _s = s;
      switch (s) {
        case 0:
          int LA12_0 = input.LA(1);

          s = -1;
          if ((LA12_0 == 'c')) {
            s = 1;
          } else if ((LA12_0 == '{')) {
            s = 2;
          } else if ((LA12_0 == '}')) {
            s = 3;
          } else if ((LA12_0 == 'n')) {
            s = 4;
          } else if ((LA12_0 == ',')) {
            s = 5;
          } else if ((LA12_0 == '-')) {
            s = 6;
          } else if ((LA12_0 == 'C')) {
            s = 7;
          } else if ((LA12_0 == '(')) {
            s = 8;
          } else if ((LA12_0 == ')')) {
            s = 9;
          } else if ((LA12_0 == 'a')) {
            s = 10;
          } else if ((LA12_0 == 'F')) {
            s = 11;
          } else if ((LA12_0 == 'S')) {
            s = 12;
          } else if ((LA12_0 == '^')) {
            s = 13;
          } else if (((LA12_0 >= 'A' && LA12_0 <= 'B')
              || (LA12_0 >= 'D' && LA12_0 <= 'E')
              || (LA12_0 >= 'G' && LA12_0 <= 'R')
              || (LA12_0 >= 'T' && LA12_0 <= 'Z')
              || LA12_0 == '_'
              || LA12_0 == 'b'
              || (LA12_0 >= 'd' && LA12_0 <= 'm')
              || (LA12_0 >= 'o' && LA12_0 <= 'z'))) {
            s = 14;
          } else if (((LA12_0 >= '0' && LA12_0 <= '9'))) {
            s = 15;
          } else if ((LA12_0 == '\"')) {
            s = 16;
          } else if ((LA12_0 == '\'')) {
            s = 17;
          } else if ((LA12_0 == '/')) {
            s = 18;
          } else if (((LA12_0 >= '\t' && LA12_0 <= '\n') || LA12_0 == '\r' || LA12_0 == ' ')) {
            s = 19;
          } else if (((LA12_0 >= '\u0000' && LA12_0 <= '\b')
              || (LA12_0 >= '\u000B' && LA12_0 <= '\f')
              || (LA12_0 >= '\u000E' && LA12_0 <= '\u001F')
              || LA12_0 == '!'
              || (LA12_0 >= '#' && LA12_0 <= '&')
              || (LA12_0 >= '*' && LA12_0 <= '+')
              || LA12_0 == '.'
              || (LA12_0 >= ':' && LA12_0 <= '@')
              || (LA12_0 >= '[' && LA12_0 <= ']')
              || LA12_0 == '`'
              || LA12_0 == '|'
              || (LA12_0 >= '~' && LA12_0 <= '\uFFFF'))) {
            s = 20;
          }

          if (s >= 0) return s;
          break;
        case 1:
          int LA12_16 = input.LA(1);

          s = -1;
          if (((LA12_16 >= '\u0000' && LA12_16 <= '\uFFFF'))) {
            s = 36;
          } else s = 20;

          if (s >= 0) return s;
          break;
        case 2:
          int LA12_17 = input.LA(1);

          s = -1;
          if (((LA12_17 >= '\u0000' && LA12_17 <= '\uFFFF'))) {
            s = 36;
          } else s = 20;

          if (s >= 0) return s;
          break;
      }
      NoViableAltException nvae = new NoViableAltException(getDescription(), 12, _s, input);
      error(nvae);
      throw nvae;
    }
    public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
      IntStream input = _input;
      int _s = s;
      switch (s) {
        case 0:
          int LA12_0 = input.LA(1);

          s = -1;
          if ((LA12_0 == ';')) {
            s = 1;
          } else if ((LA12_0 == 'r')) {
            s = 2;
          } else if ((LA12_0 == '^')) {
            s = 3;
          } else if (((LA12_0 >= 'A' && LA12_0 <= 'Z')
              || LA12_0 == '_'
              || (LA12_0 >= 'a' && LA12_0 <= 'q')
              || (LA12_0 >= 's' && LA12_0 <= 'z'))) {
            s = 4;
          } else if (((LA12_0 >= '0' && LA12_0 <= '9'))) {
            s = 5;
          } else if ((LA12_0 == '\"')) {
            s = 6;
          } else if ((LA12_0 == '\'')) {
            s = 7;
          } else if ((LA12_0 == '/')) {
            s = 8;
          } else if (((LA12_0 >= '\t' && LA12_0 <= '\n') || LA12_0 == '\r' || LA12_0 == ' ')) {
            s = 9;
          } else if (((LA12_0 >= '\u0000' && LA12_0 <= '\b')
              || (LA12_0 >= '\u000B' && LA12_0 <= '\f')
              || (LA12_0 >= '\u000E' && LA12_0 <= '\u001F')
              || LA12_0 == '!'
              || (LA12_0 >= '#' && LA12_0 <= '&')
              || (LA12_0 >= '(' && LA12_0 <= '.')
              || LA12_0 == ':'
              || (LA12_0 >= '<' && LA12_0 <= '@')
              || (LA12_0 >= '[' && LA12_0 <= ']')
              || LA12_0 == '`'
              || (LA12_0 >= '{' && LA12_0 <= '\uFFFF'))) {
            s = 10;
          }

          if (s >= 0) return s;
          break;
        case 1:
          int LA12_7 = input.LA(1);

          s = -1;
          if (((LA12_7 >= '\u0000' && LA12_7 <= '\uFFFF'))) {
            s = 15;
          } else s = 10;

          if (s >= 0) return s;
          break;
        case 2:
          int LA12_6 = input.LA(1);

          s = -1;
          if (((LA12_6 >= '\u0000' && LA12_6 <= '\uFFFF'))) {
            s = 15;
          } else s = 10;

          if (s >= 0) return s;
          break;
      }
      NoViableAltException nvae = new NoViableAltException(getDescription(), 12, _s, input);
      error(nvae);
      throw nvae;
    }
Ejemplo n.º 21
0
 public void deleteModule(int section, int module) {
   intStream = appendAll();
   intStream.append(section);
   intStream.append(module);
 }
Ejemplo n.º 22
0
 /**
  * Record whether or not this rule parsed the input at this position successfully. Use a standard
  * java hashtable for now.
  */
 public void memoize(IntStream input, int ruleIndex, int ruleStartIndex) {
   int stopTokenIndex = failed ? MEMO_RULE_FAILED : input.index() - 1;
   if (ruleMemo[ruleIndex] != null) {
     ruleMemo[ruleIndex].put(new Integer(ruleStartIndex), new Integer(stopTokenIndex));
   }
 }
Ejemplo n.º 23
0
    public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
      IntStream input = _input;
      int _s = s;
      switch (s) {
        case 0:
          int LA13_0 = input.LA(1);

          s = -1;
          if ((LA13_0 == '[')) {
            s = 1;
          } else if ((LA13_0 == ']')) {
            s = 2;
          } else if ((LA13_0 == '(')) {
            s = 3;
          } else if ((LA13_0 == ',')) {
            s = 4;
          } else if ((LA13_0 == ')')) {
            s = 5;
          } else if ((LA13_0 == '=')) {
            s = 6;
          } else if ((LA13_0 == '<')) {
            s = 7;
          } else if ((LA13_0 == '>')) {
            s = 8;
          } else if ((LA13_0 == '.')) {
            s = 9;
          } else if ((LA13_0 == '?')) {
            s = 10;
          } else if ((LA13_0 == 'e')) {
            s = 11;
          } else if ((LA13_0 == '&')) {
            s = 12;
          } else if ((LA13_0 == 's')) {
            s = 13;
          } else if ((LA13_0 == '*')) {
            s = 14;
          } else if ((LA13_0 == 'i')) {
            s = 15;
          } else if ((LA13_0 == ';')) {
            s = 16;
          } else if ((LA13_0 == '^')) {
            s = 17;
          } else if ((LA13_0 == '$'
              || (LA13_0 >= 'A' && LA13_0 <= 'Z')
              || LA13_0 == '_'
              || (LA13_0 >= 'a' && LA13_0 <= 'd')
              || (LA13_0 >= 'f' && LA13_0 <= 'h')
              || (LA13_0 >= 'j' && LA13_0 <= 'r')
              || (LA13_0 >= 't' && LA13_0 <= 'z'))) {
            s = 18;
          } else if ((LA13_0 == '\"')) {
            s = 19;
          } else if ((LA13_0 == '\'')) {
            s = 20;
          } else if ((LA13_0 == '/')) {
            s = 21;
          } else if (((LA13_0 >= '\t' && LA13_0 <= '\n') || LA13_0 == '\r' || LA13_0 == ' ')) {
            s = 22;
          } else if (((LA13_0 >= '\u0000' && LA13_0 <= '\b')
              || (LA13_0 >= '\u000B' && LA13_0 <= '\f')
              || (LA13_0 >= '\u000E' && LA13_0 <= '\u001F')
              || LA13_0 == '!'
              || LA13_0 == '#'
              || LA13_0 == '%'
              || LA13_0 == '+'
              || LA13_0 == '-'
              || (LA13_0 >= '0' && LA13_0 <= ':')
              || LA13_0 == '@'
              || LA13_0 == '\\'
              || LA13_0 == '`'
              || (LA13_0 >= '{' && LA13_0 <= '\uFFFF'))) {
            s = 23;
          }

          if (s >= 0) return s;
          break;
      }
      NoViableAltException nvae = new NoViableAltException(getDescription(), 13, _s, input);
      error(nvae);
      throw nvae;
    }
Ejemplo n.º 24
0
    public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
      IntStream input = _input;
      int _s = s;
      switch (s) {
        case 0:
          int LA12_19 = input.LA(1);

          s = -1;
          if (((LA12_19 >= '\u0000' && LA12_19 <= '\uFFFF'))) {
            s = 40;
          } else s = 22;

          if (s >= 0) return s;
          break;
        case 1:
          int LA12_0 = input.LA(1);

          s = -1;
          if ((LA12_0 == 'u')) {
            s = 1;
          } else if ((LA12_0 == 'v')) {
            s = 2;
          } else if ((LA12_0 == 'i')) {
            s = 3;
          } else if ((LA12_0 == 'T')) {
            s = 4;
          } else if ((LA12_0 == ':')) {
            s = 5;
          } else if ((LA12_0 == '(')) {
            s = 6;
          } else if ((LA12_0 == ')')) {
            s = 7;
          } else if ((LA12_0 == ',')) {
            s = 8;
          } else if ((LA12_0 == '-')) {
            s = 9;
          } else if ((LA12_0 == '^')) {
            s = 10;
          } else if ((LA12_0 == '.')) {
            s = 11;
          } else if ((LA12_0 == '{')) {
            s = 12;
          } else if ((LA12_0 == '}')) {
            s = 13;
          } else if ((LA12_0 == 'h')) {
            s = 14;
          } else if ((LA12_0 == 'e')) {
            s = 15;
          } else if (((LA12_0 >= 'A' && LA12_0 <= 'S')
              || (LA12_0 >= 'U' && LA12_0 <= 'Z')
              || LA12_0 == '_'
              || (LA12_0 >= 'a' && LA12_0 <= 'd')
              || (LA12_0 >= 'f' && LA12_0 <= 'g')
              || (LA12_0 >= 'j' && LA12_0 <= 't')
              || (LA12_0 >= 'w' && LA12_0 <= 'z'))) {
            s = 16;
          } else if (((LA12_0 >= '0' && LA12_0 <= '9'))) {
            s = 17;
          } else if ((LA12_0 == '\"')) {
            s = 18;
          } else if ((LA12_0 == '\'')) {
            s = 19;
          } else if ((LA12_0 == '/')) {
            s = 20;
          } else if (((LA12_0 >= '\t' && LA12_0 <= '\n') || LA12_0 == '\r' || LA12_0 == ' ')) {
            s = 21;
          } else if (((LA12_0 >= '\u0000' && LA12_0 <= '\b')
              || (LA12_0 >= '\u000B' && LA12_0 <= '\f')
              || (LA12_0 >= '\u000E' && LA12_0 <= '\u001F')
              || LA12_0 == '!'
              || (LA12_0 >= '#' && LA12_0 <= '&')
              || (LA12_0 >= '*' && LA12_0 <= '+')
              || (LA12_0 >= ';' && LA12_0 <= '@')
              || (LA12_0 >= '[' && LA12_0 <= ']')
              || LA12_0 == '`'
              || LA12_0 == '|'
              || (LA12_0 >= '~' && LA12_0 <= '\uFFFF'))) {
            s = 22;
          }

          if (s >= 0) return s;
          break;
        case 2:
          int LA12_18 = input.LA(1);

          s = -1;
          if (((LA12_18 >= '\u0000' && LA12_18 <= '\uFFFF'))) {
            s = 40;
          } else s = 22;

          if (s >= 0) return s;
          break;
      }
      NoViableAltException nvae = new NoViableAltException(getDescription(), 12, _s, input);
      error(nvae);
      throw nvae;
    }
Ejemplo n.º 25
0
    public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
      IntStream input = _input;
      int _s = s;
      switch (s) {
        case 0:
          int LA12_35 = input.LA(1);

          s = -1;
          if (((LA12_35 >= '\u0000' && LA12_35 <= '\uFFFF'))) {
            s = 81;
          } else s = 39;

          if (s >= 0) return s;
          break;
        case 1:
          int LA12_0 = input.LA(1);

          s = -1;
          if ((LA12_0 == '?')) {
            s = 1;
          } else if ((LA12_0 == '*')) {
            s = 2;
          } else if ((LA12_0 == '+')) {
            s = 3;
          } else if ((LA12_0 == '=')) {
            s = 4;
          } else if ((LA12_0 == 'f')) {
            s = 5;
          } else if ((LA12_0 == 't')) {
            s = 6;
          } else if ((LA12_0 == 'g')) {
            s = 7;
          } else if ((LA12_0 == 'w')) {
            s = 8;
          } else if ((LA12_0 == ',')) {
            s = 9;
          } else if ((LA12_0 == '(')) {
            s = 10;
          } else if ((LA12_0 == ')')) {
            s = 11;
          } else if ((LA12_0 == '.')) {
            s = 12;
          } else if ((LA12_0 == 'a')) {
            s = 13;
          } else if ((LA12_0 == 'i')) {
            s = 14;
          } else if ((LA12_0 == ':')) {
            s = 15;
          } else if ((LA12_0 == ';')) {
            s = 16;
          } else if ((LA12_0 == 'r')) {
            s = 17;
          } else if ((LA12_0 == '<')) {
            s = 18;
          } else if ((LA12_0 == '>')) {
            s = 19;
          } else if ((LA12_0 == '|')) {
            s = 20;
          } else if ((LA12_0 == '&')) {
            s = 21;
          } else if ((LA12_0 == '{')) {
            s = 22;
          } else if ((LA12_0 == '}')) {
            s = 23;
          } else if ((LA12_0 == 'c')) {
            s = 24;
          } else if ((LA12_0 == '!')) {
            s = 25;
          } else if ((LA12_0 == '[')) {
            s = 26;
          } else if ((LA12_0 == ']')) {
            s = 27;
          } else if ((LA12_0 == '-')) {
            s = 28;
          } else if ((LA12_0 == 'E')) {
            s = 29;
          } else if ((LA12_0 == 'e')) {
            s = 30;
          } else if ((LA12_0 == 'h')) {
            s = 31;
          } else if ((LA12_0 == '^')) {
            s = 32;
          } else if (((LA12_0 >= 'A' && LA12_0 <= 'D')
              || (LA12_0 >= 'F' && LA12_0 <= 'Z')
              || LA12_0 == '_'
              || LA12_0 == 'b'
              || LA12_0 == 'd'
              || (LA12_0 >= 'j' && LA12_0 <= 'q')
              || LA12_0 == 's'
              || (LA12_0 >= 'u' && LA12_0 <= 'v')
              || (LA12_0 >= 'x' && LA12_0 <= 'z'))) {
            s = 33;
          } else if (((LA12_0 >= '0' && LA12_0 <= '9'))) {
            s = 34;
          } else if ((LA12_0 == '\"')) {
            s = 35;
          } else if ((LA12_0 == '\'')) {
            s = 36;
          } else if ((LA12_0 == '/')) {
            s = 37;
          } else if (((LA12_0 >= '\t' && LA12_0 <= '\n') || LA12_0 == '\r' || LA12_0 == ' ')) {
            s = 38;
          } else if (((LA12_0 >= '\u0000' && LA12_0 <= '\b')
              || (LA12_0 >= '\u000B' && LA12_0 <= '\f')
              || (LA12_0 >= '\u000E' && LA12_0 <= '\u001F')
              || (LA12_0 >= '#' && LA12_0 <= '%')
              || LA12_0 == '@'
              || LA12_0 == '\\'
              || LA12_0 == '`'
              || (LA12_0 >= '~' && LA12_0 <= '\uFFFF'))) {
            s = 39;
          }

          if (s >= 0) return s;
          break;
        case 2:
          int LA12_36 = input.LA(1);

          s = -1;
          if (((LA12_36 >= '\u0000' && LA12_36 <= '\uFFFF'))) {
            s = 81;
          } else s = 39;

          if (s >= 0) return s;
          break;
      }
      NoViableAltException nvae = new NoViableAltException(getDescription(), 12, _s, input);
      error(nvae);
      throw nvae;
    }
Ejemplo n.º 26
0
 public void matchAny(IntStream input) {
   errorRecovery = false;
   failed = false;
   input.consume();
 }
    public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
      IntStream input = _input;
      int _s = s;
      switch (s) {
        case 0:
          int LA12_19 = input.LA(1);

          s = -1;
          if (((LA12_19 >= '\u0000' && LA12_19 <= '\uFFFF'))) {
            s = 45;
          } else s = 23;

          if (s >= 0) return s;
          break;
        case 1:
          int LA12_0 = input.LA(1);

          s = -1;
          if ((LA12_0 == 'V')) {
            s = 1;
          } else if ((LA12_0 == '@')) {
            s = 2;
          } else if ((LA12_0 == 'A')) {
            s = 3;
          } else if ((LA12_0 == ')')) {
            s = 4;
          } else if ((LA12_0 == 'S')) {
            s = 5;
          } else if ((LA12_0 == 'u')) {
            s = 6;
          } else if ((LA12_0 == 'd')) {
            s = 7;
          } else if ((LA12_0 == 'l')) {
            s = 8;
          } else if ((LA12_0 == 'm')) {
            s = 9;
          } else if ((LA12_0 == 'N')) {
            s = 10;
          } else if ((LA12_0 == 'M')) {
            s = 11;
          } else if ((LA12_0 == 'F')) {
            s = 12;
          } else if ((LA12_0 == 'W')) {
            s = 13;
          } else if ((LA12_0 == '{')) {
            s = 14;
          } else if ((LA12_0 == '}')) {
            s = 15;
          } else if ((LA12_0 == '^')) {
            s = 16;
          } else if (((LA12_0 >= 'B' && LA12_0 <= 'E')
              || (LA12_0 >= 'G' && LA12_0 <= 'L')
              || (LA12_0 >= 'O' && LA12_0 <= 'R')
              || (LA12_0 >= 'T' && LA12_0 <= 'U')
              || (LA12_0 >= 'X' && LA12_0 <= 'Z')
              || LA12_0 == '_'
              || (LA12_0 >= 'a' && LA12_0 <= 'c')
              || (LA12_0 >= 'e' && LA12_0 <= 'k')
              || (LA12_0 >= 'n' && LA12_0 <= 't')
              || (LA12_0 >= 'v' && LA12_0 <= 'z'))) {
            s = 17;
          } else if (((LA12_0 >= '0' && LA12_0 <= '9'))) {
            s = 18;
          } else if ((LA12_0 == '\"')) {
            s = 19;
          } else if ((LA12_0 == '\'')) {
            s = 20;
          } else if ((LA12_0 == '/')) {
            s = 21;
          } else if (((LA12_0 >= '\t' && LA12_0 <= '\n') || LA12_0 == '\r' || LA12_0 == ' ')) {
            s = 22;
          } else if (((LA12_0 >= '\u0000' && LA12_0 <= '\b')
              || (LA12_0 >= '\u000B' && LA12_0 <= '\f')
              || (LA12_0 >= '\u000E' && LA12_0 <= '\u001F')
              || LA12_0 == '!'
              || (LA12_0 >= '#' && LA12_0 <= '&')
              || LA12_0 == '('
              || (LA12_0 >= '*' && LA12_0 <= '.')
              || (LA12_0 >= ':' && LA12_0 <= '?')
              || (LA12_0 >= '[' && LA12_0 <= ']')
              || LA12_0 == '`'
              || LA12_0 == '|'
              || (LA12_0 >= '~' && LA12_0 <= '\uFFFF'))) {
            s = 23;
          }

          if (s >= 0) return s;
          break;
        case 2:
          int LA12_20 = input.LA(1);

          s = -1;
          if (((LA12_20 >= '\u0000' && LA12_20 <= '\uFFFF'))) {
            s = 45;
          } else s = 23;

          if (s >= 0) return s;
          break;
      }
      NoViableAltException nvae = new NoViableAltException(getDescription(), 12, _s, input);
      error(nvae);
      throw nvae;
    }
    public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
      IntStream input = _input;
      int _s = s;
      switch (s) {
        case 0:
          int LA12_11 = input.LA(1);

          s = -1;
          if (((LA12_11 >= '\u0000' && LA12_11 <= '\uFFFF'))) {
            s = 26;
          } else s = 14;

          if (s >= 0) return s;
          break;
        case 1:
          int LA12_0 = input.LA(1);

          s = -1;
          if ((LA12_0 == 'm')) {
            s = 1;
          } else if ((LA12_0 == ':')) {
            s = 2;
          } else if ((LA12_0 == 'o')) {
            s = 3;
          } else if ((LA12_0 == '-')) {
            s = 4;
          } else if ((LA12_0 == 's')) {
            s = 5;
          } else if ((LA12_0 == 'e')) {
            s = 6;
          } else if ((LA12_0 == '^')) {
            s = 7;
          } else if (((LA12_0 >= 'A' && LA12_0 <= 'Z')
              || LA12_0 == '_'
              || (LA12_0 >= 'a' && LA12_0 <= 'd')
              || (LA12_0 >= 'f' && LA12_0 <= 'l')
              || LA12_0 == 'n'
              || (LA12_0 >= 'p' && LA12_0 <= 'r')
              || (LA12_0 >= 't' && LA12_0 <= 'z')
              || LA12_0 == '\u00E4'
              || LA12_0 == '\u00F6'
              || LA12_0 == '\u00FC')) {
            s = 8;
          } else if (((LA12_0 >= '0' && LA12_0 <= '9'))) {
            s = 9;
          } else if ((LA12_0 == '\"')) {
            s = 10;
          } else if ((LA12_0 == '\'')) {
            s = 11;
          } else if ((LA12_0 == '/')) {
            s = 12;
          } else if (((LA12_0 >= '\t' && LA12_0 <= '\n') || LA12_0 == '\r' || LA12_0 == ' ')) {
            s = 13;
          } else if (((LA12_0 >= '\u0000' && LA12_0 <= '\b')
              || (LA12_0 >= '\u000B' && LA12_0 <= '\f')
              || (LA12_0 >= '\u000E' && LA12_0 <= '\u001F')
              || LA12_0 == '!'
              || (LA12_0 >= '#' && LA12_0 <= '&')
              || (LA12_0 >= '(' && LA12_0 <= ',')
              || LA12_0 == '.'
              || (LA12_0 >= ';' && LA12_0 <= '@')
              || (LA12_0 >= '[' && LA12_0 <= ']')
              || LA12_0 == '`'
              || (LA12_0 >= '{' && LA12_0 <= '\u00E3')
              || (LA12_0 >= '\u00E5' && LA12_0 <= '\u00F5')
              || (LA12_0 >= '\u00F7' && LA12_0 <= '\u00FB')
              || (LA12_0 >= '\u00FD' && LA12_0 <= '\uFFFF'))) {
            s = 14;
          }

          if (s >= 0) return s;
          break;
        case 2:
          int LA12_10 = input.LA(1);

          s = -1;
          if (((LA12_10 >= '\u0000' && LA12_10 <= '\uFFFF'))) {
            s = 26;
          } else s = 14;

          if (s >= 0) return s;
          break;
      }
      NoViableAltException nvae = new NoViableAltException(getDescription(), 12, _s, input);
      error(nvae);
      throw nvae;
    }
Ejemplo n.º 29
0
    public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
      IntStream input = _input;
      int _s = s;
      switch (s) {
        case 0:
          int LA12_14 = input.LA(1);

          s = -1;
          if (((LA12_14 >= '\u0000' && LA12_14 <= '\uFFFF'))) {
            s = 31;
          } else s = 17;

          if (s >= 0) return s;
          break;
        case 1:
          int LA12_13 = input.LA(1);

          s = -1;
          if (((LA12_13 >= '\u0000' && LA12_13 <= '\uFFFF'))) {
            s = 31;
          } else s = 17;

          if (s >= 0) return s;
          break;
        case 2:
          int LA12_0 = input.LA(1);

          s = -1;
          if ((LA12_0 == 'a')) {
            s = 1;
          } else if ((LA12_0 == 'c')) {
            s = 2;
          } else if ((LA12_0 == 'd')) {
            s = 3;
          } else if ((LA12_0 == 't')) {
            s = 4;
          } else if ((LA12_0 == 'f')) {
            s = 5;
          } else if ((LA12_0 == 'p')) {
            s = 6;
          } else if ((LA12_0 == 'e')) {
            s = 7;
          } else if ((LA12_0 == '(')) {
            s = 8;
          } else if ((LA12_0 == ')')) {
            s = 9;
          } else if ((LA12_0 == '^')) {
            s = 10;
          } else if (((LA12_0 >= 'A' && LA12_0 <= 'Z')
              || LA12_0 == '_'
              || LA12_0 == 'b'
              || (LA12_0 >= 'g' && LA12_0 <= 'o')
              || (LA12_0 >= 'q' && LA12_0 <= 's')
              || (LA12_0 >= 'u' && LA12_0 <= 'z'))) {
            s = 11;
          } else if (((LA12_0 >= '0' && LA12_0 <= '9'))) {
            s = 12;
          } else if ((LA12_0 == '\"')) {
            s = 13;
          } else if ((LA12_0 == '\'')) {
            s = 14;
          } else if ((LA12_0 == '/')) {
            s = 15;
          } else if (((LA12_0 >= '\t' && LA12_0 <= '\n') || LA12_0 == '\r' || LA12_0 == ' ')) {
            s = 16;
          } else if (((LA12_0 >= '\u0000' && LA12_0 <= '\b')
              || (LA12_0 >= '\u000B' && LA12_0 <= '\f')
              || (LA12_0 >= '\u000E' && LA12_0 <= '\u001F')
              || LA12_0 == '!'
              || (LA12_0 >= '#' && LA12_0 <= '&')
              || (LA12_0 >= '*' && LA12_0 <= '.')
              || (LA12_0 >= ':' && LA12_0 <= '@')
              || (LA12_0 >= '[' && LA12_0 <= ']')
              || LA12_0 == '`'
              || (LA12_0 >= '{' && LA12_0 <= '\uFFFF'))) {
            s = 17;
          }

          if (s >= 0) return s;
          break;
      }
      NoViableAltException nvae = new NoViableAltException(getDescription(), 12, _s, input);
      error(nvae);
      throw nvae;
    }
Ejemplo n.º 30
0
    public void requestExamples() {
      // #ws-holder
      WSRequest request = ws.url("http://example.com");
      // #ws-holder

      // #ws-complex-holder
      WSRequest complexRequest =
          request
              .setHeader("headerKey", "headerValue")
              .setRequestTimeout(1000)
              .setQueryParameter("paramKey", "paramValue");
      // #ws-complex-holder

      // #ws-get
      CompletionStage<WSResponse> responsePromise = complexRequest.get();
      // #ws-get

      String url = "http://example.com";
      // #ws-auth
      ws.url(url).setAuth("user", "password", WSAuthScheme.BASIC).get();
      // #ws-auth

      // #ws-follow-redirects
      ws.url(url).setFollowRedirects(true).get();
      // #ws-follow-redirects

      // #ws-query-parameter
      ws.url(url).setQueryParameter("paramKey", "paramValue");
      // #ws-query-parameter

      // #ws-header
      ws.url(url).setHeader("headerKey", "headerValue").get();
      // #ws-header

      String jsonString = "{\"key1\":\"value1\"}";
      // #ws-header-content-type
      ws.url(url).setHeader("Content-Type", "application/json").post(jsonString);
      // OR
      ws.url(url).setContentType("application/json").post(jsonString);
      // #ws-header-content-type

      // #ws-timeout
      ws.url(url).setRequestTimeout(1000).get();
      // #ws-timeout

      // #ws-post-form-data
      ws.url(url)
          .setContentType("application/x-www-form-urlencoded")
          .post("key1=value1&key2=value2");
      // #ws-post-form-data

      // #ws-post-json
      JsonNode json = Json.newObject().put("key1", "value1").put("key2", "value2");

      ws.url(url).post(json);
      // #ws-post-json

      String value =
          IntStream.range(0, 100).boxed().map(i -> "abcdefghij").reduce("", (a, b) -> a + b);
      ByteString seedValue = ByteString.fromString(value);
      Stream<ByteString> largeSource = IntStream.range(0, 10).boxed().map(i -> seedValue);
      Source<ByteString, ?> largeImage = Source.from(largeSource.collect(Collectors.toList()));
      // #ws-stream-request
      CompletionStage<WSResponse> wsResponse = ws.url(url).setBody(largeImage).execute("PUT");
      // #ws-stream-request
    }