Get the parser for the current syntax.

@param syntax the current syntax of the title content
@return the parser for the current syntax
@throws org.xwiki.rendering.macro.MacroExecutionException Failed to find source parser.
484485
private Parser getSyntaxParser(Syntax syntax) throws MacroExecutionException
    {
        try {
            return this.componentManager.getInstance(Parser.class, syntax.toIdString());
        } catch (ComponentLookupException e) {
            throw new MacroExecutionException("Failed to find source parser for syntax [" + syntax + "]", e);
        }
    }
504060
public static void translate(Syntax syntax, Definition source, Definition target) throws GenericException {
        List<Definition> targets;
        IntBitSet stopper;

        targets = new ArrayList<Definition>();
        targets.add(target);
        stopper = new IntBitSet();
        stopper.add(target.getAttribute().symbol);
        translate(syntax, ISOLATED, source, targets, new int[] {}, new IntBitSet[] { stopper });
    }
608026
public final JavaParser.expression_return expression() throws RecognitionException {
		JavaParser.expression_return retval = new JavaParser.expression_return();
		retval.start = input.LT(1);
		int expression_StartIndex = input.index();

		try {
			if ( state.backtracking>0 && alreadyParsedRule(input, 108) ) { return retval; }

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1119:5: ( conditionalExpression ( assignmentOperator expression )? )
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1119:7: conditionalExpression ( assignmentOperator expression )?
			{
			pushFollow(FOLLOW_conditionalExpression_in_expression4875);
			conditionalExpression();
			state._fsp--;
			if (state.failed) return retval;
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1119:29: ( assignmentOperator expression )?
			int alt140=2;
			alt140 = dfa140.predict(input);
			switch (alt140) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1119:30: assignmentOperator expression
					{
					pushFollow(FOLLOW_assignmentOperator_in_expression4878);
					assignmentOperator();
					state._fsp--;
					if (state.failed) return retval;
					pushFollow(FOLLOW_expression_in_expression4880);
					expression();
					state._fsp--;
					if (state.failed) return retval;
					}
					break;

			}

			}

			retval.stop = input.LT(-1);

		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
			if ( state.backtracking>0 ) { memoize(input, 108, expression_StartIndex); }

		}
		return retval;
	}
798938
public final BELScriptParser.define_annotation_return define_annotation() throws RecognitionException {
        BELScriptParser.define_annotation_return retval = new BELScriptParser.define_annotation_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token vl=null;
        Token string_literal40=null;
        Token string_literal41=null;
        Token OBJECT_IDENT42=null;
        Token string_literal43=null;
        Token set44=null;
        Token string_literal46=null;
        BELScriptParser.quoted_value_return quoted_value45 = null;


        Object vl_tree=null;
        Object string_literal40_tree=null;
        Object string_literal41_tree=null;
        Object OBJECT_IDENT42_tree=null;
        Object string_literal43_tree=null;
        Object set44_tree=null;
        Object string_literal46_tree=null;

         paraphrases.push("in define annotation."); 
        try {
            // BELScript.g:105:5: ( ( 'DEFINE' 'ANNOTATION' ) OBJECT_IDENT 'AS' ( ( ( 'URL' | 'PATTERN' ) quoted_value ) | ( 'LIST' vl= VALUE_LIST ) ) )
            // BELScript.g:106:5: ( 'DEFINE' 'ANNOTATION' ) OBJECT_IDENT 'AS' ( ( ( 'URL' | 'PATTERN' ) quoted_value ) | ( 'LIST' vl= VALUE_LIST ) )
            {
            root_0 = (Object)adaptor.nil();

            // BELScript.g:106:5: ( 'DEFINE' 'ANNOTATION' )
            // BELScript.g:106:6: 'DEFINE' 'ANNOTATION'
            {
            string_literal40=(Token)match(input,27,FOLLOW_27_in_define_annotation487); 
            string_literal40_tree = (Object)adaptor.create(string_literal40);
            adaptor.addChild(root_0, string_literal40_tree);

            string_literal41=(Token)match(input,32,FOLLOW_32_in_define_annotation489); 
            string_literal41_tree = (Object)adaptor.create(string_literal41);
            adaptor.addChild(root_0, string_literal41_tree);


            }

            OBJECT_IDENT42=(Token)match(input,OBJECT_IDENT,FOLLOW_OBJECT_IDENT_in_define_annotation492); 
            OBJECT_IDENT42_tree = (Object)adaptor.create(OBJECT_IDENT42);
            adaptor.addChild(root_0, OBJECT_IDENT42_tree);

            string_literal43=(Token)match(input,30,FOLLOW_30_in_define_annotation494); 
            string_literal43_tree = (Object)adaptor.create(string_literal43);
            adaptor.addChild(root_0, string_literal43_tree);

            // BELScript.g:106:47: ( ( ( 'URL' | 'PATTERN' ) quoted_value ) | ( 'LIST' vl= VALUE_LIST ) )
            int alt7=2;
            int LA7_0 = input.LA(1);

            if ( (LA7_0==31||LA7_0==33) ) {
                alt7=1;
            }
            else if ( (LA7_0==34) ) {
                alt7=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 7, 0, input);

                throw nvae;
            }
            switch (alt7) {
                case 1 :
                    // BELScript.g:106:48: ( ( 'URL' | 'PATTERN' ) quoted_value )
                    {
                    // BELScript.g:106:48: ( ( 'URL' | 'PATTERN' ) quoted_value )
                    // BELScript.g:106:49: ( 'URL' | 'PATTERN' ) quoted_value
                    {
                    set44=(Token)input.LT(1);
                    if ( input.LA(1)==31||input.LA(1)==33 ) {
                        input.consume();
                        adaptor.addChild(root_0, (Object)adaptor.create(set44));
                        state.errorRecovery=false;
                    }
                    else {
                        MismatchedSetException mse = new MismatchedSetException(null,input);
                        throw mse;
                    }

                    pushFollow(FOLLOW_quoted_value_in_define_annotation506);
                    quoted_value45=quoted_value();

                    state._fsp--;

                    adaptor.addChild(root_0, quoted_value45.getTree());

                    }


                    }
                    break;
                case 2 :
                    // BELScript.g:106:85: ( 'LIST' vl= VALUE_LIST )
                    {
                    // BELScript.g:106:85: ( 'LIST' vl= VALUE_LIST )
                    // BELScript.g:106:86: 'LIST' vl= VALUE_LIST
                    {
                    string_literal46=(Token)match(input,34,FOLLOW_34_in_define_annotation512); 
                    string_literal46_tree = (Object)adaptor.create(string_literal46);
                    adaptor.addChild(root_0, string_literal46_tree);

                    vl=(Token)match(input,VALUE_LIST,FOLLOW_VALUE_LIST_in_define_annotation516); 
                    vl_tree = (Object)adaptor.create(vl);
                    adaptor.addChild(root_0, vl_tree);


                    }


                    }
                    break;

            }


                    // https://github.com/OpenBEL/openbel-framework/issues/14
                    if (vl != null) vl.setText(vl.getText().replace("\\\\", "\\"));
                

            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

             paraphrases.pop(); 
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
1036735
public QueryBuilderKraken parse()
  {
    Token token = scanToken();

    switch (token) {
    case CREATE:
      return parseCreate();
      
    case EXPLAIN:
      return parseExplain();

    case INSERT:
      return parseInsert();

    case REPLACE:
      return parseReplace();
      
    case SELECT:
      return parseSelect();
      
    case SELECT_LOCAL:
      return parseSelectLocal();
      
    case MAP:
      return parseMap();
      
    case SHOW:
      return parseShow();
      
    case UPDATE:
      return parseUpdate();
      
    case DELETE:
      return parseDelete();
      
    case WATCH:
      return parseWatch();
      
      /*
    case NOTIFY:
      return parseNotify();
      */

      /*
    case VALIDATE:
      return parseValidate();

    case DROP:
      return parseDrop();
*/
      
    case IDENTIFIER:
      if (_lexeme.equalsIgnoreCase("checkpoint")) {
        return parseCheckpoint();
      }
      
    default:
      throw error("unknown query at {0}", token);
    }
  }
579306
public AbstractType<?> parse() throws SyntaxException, ConfigurationException
    {
        skipBlank();
        String name = readNextIdentifier();

        skipBlank();
        if (!isEOS() && str.charAt(idx) == '(')
            return getAbstractType(name, this);
        else
            return getAbstractType(name);
    }
911706
public final void compilationUnit() throws RecognitionException {
		int compilationUnit_StartIndex = input.index();

		try {
			if ( state.backtracking>0 && alreadyParsedRule(input, 1) ) { return; }

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:270:5: ( ( annotations )? ( packageDeclaration )? ( importDeclaration )* ( typeDeclaration )* )
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:270:7: ( annotations )? ( packageDeclaration )? ( importDeclaration )* ( typeDeclaration )*
			{
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:270:7: ( annotations )?
			int alt1=2;
			int LA1_0 = input.LA(1);
			if ( (LA1_0==58) ) {
				int LA1_1 = input.LA(2);
				if ( (LA1_1==Identifier) ) {
					int LA1_21 = input.LA(3);
					if ( (synpred1_Java()) ) {
						alt1=1;
					}
				}
			}
			switch (alt1) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:270:7: annotations
					{
					pushFollow(FOLLOW_annotations_in_compilationUnit81);
					annotations();
					state._fsp--;
					if (state.failed) return;
					}
					break;

			}

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:271:9: ( packageDeclaration )?
			int alt2=2;
			int LA2_0 = input.LA(1);
			if ( (LA2_0==99) ) {
				alt2=1;
			}
			switch (alt2) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:271:9: packageDeclaration
					{
					pushFollow(FOLLOW_packageDeclaration_in_compilationUnit92);
					packageDeclaration();
					state._fsp--;
					if (state.failed) return;
					}
					break;

			}

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:272:9: ( importDeclaration )*
			loop3:
			while (true) {
				int alt3=2;
				int LA3_0 = input.LA(1);
				if ( (LA3_0==89) ) {
					alt3=1;
				}

				switch (alt3) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:272:9: importDeclaration
					{
					pushFollow(FOLLOW_importDeclaration_in_compilationUnit103);
					importDeclaration();
					state._fsp--;
					if (state.failed) return;
					}
					break;

				default :
					break loop3;
				}
			}

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:273:9: ( typeDeclaration )*
			loop4:
			while (true) {
				int alt4=2;
				int LA4_0 = input.LA(1);
				if ( (LA4_0==ENUM||LA4_0==52||LA4_0==58||LA4_0==63||LA4_0==72||LA4_0==83||LA4_0==93||LA4_0==96||(LA4_0 >= 100 && LA4_0 <= 102)||(LA4_0 >= 106 && LA4_0 <= 107)||LA4_0==110||LA4_0==114||LA4_0==119) ) {
					alt4=1;
				}

				switch (alt4) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:273:9: typeDeclaration
					{
					pushFollow(FOLLOW_typeDeclaration_in_compilationUnit114);
					typeDeclaration();
					state._fsp--;
					if (state.failed) return;
					}
					break;

				default :
					break loop4;
				}
			}

			}

		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
			if ( state.backtracking>0 ) { memoize(input, 1, compilationUnit_StartIndex); }

		}
	}
1175863
public final void mJavaLetterOrDigit() throws RecognitionException {
		try {
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1388:2: ( ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '$' | '_' ) |{...}?~ ( '\\u0000' .. '\\u007F' | '\\uD800' .. '\\uDBFF' ) |{...}? ( '\\uD800' .. '\\uDBFF' ) ( '\\uDC00' .. '\\uDFFF' ) )
			int alt28=3;
			int LA28_0 = input.LA(1);
			if ( (LA28_0=='$'||(LA28_0 >= '0' && LA28_0 <= '9')||(LA28_0 >= 'A' && LA28_0 <= 'Z')||LA28_0=='_'||(LA28_0 >= 'a' && LA28_0 <= 'z')) ) {
				alt28=1;
			}
			else if ( ((LA28_0 >= '\u0080' && LA28_0 <= '\uD7FF')||(LA28_0 >= '\uDC00' && LA28_0 <= '\uFFFF')) ) {
				alt28=2;
			}
			else if ( ((LA28_0 >= '\uD800' && LA28_0 <= '\uDBFF')) ) {
				alt28=3;
			}

			else {
				NoViableAltException nvae =
					new NoViableAltException("", 28, 0, input);
				throw nvae;
			}

			switch (alt28) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1388:4: ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '$' | '_' )
					{
					if ( input.LA(1)=='$'||(input.LA(1) >= '0' && input.LA(1) <= '9')||(input.LA(1) >= 'A' && input.LA(1) <= 'Z')||input.LA(1)=='_'||(input.LA(1) >= 'a' && input.LA(1) <= 'z') ) {
						input.consume();
					}
					else {
						MismatchedSetException mse = new MismatchedSetException(null,input);
						recover(mse);
						throw mse;
					}
					}
					break;
				case 2 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1389:9: {...}?~ ( '\\u0000' .. '\\u007F' | '\\uD800' .. '\\uDBFF' )
					{
					if ( !((Character.isJavaIdentifierPart(input.LA(1)))) ) {
						throw new FailedPredicateException(input, "JavaLetterOrDigit", "Character.isJavaIdentifierPart(input.LA(1))");
					}
					if ( (input.LA(1) >= '\u0080' && input.LA(1) <= '\uD7FF')||(input.LA(1) >= '\uDC00' && input.LA(1) <= '\uFFFF') ) {
						input.consume();
					}
					else {
						MismatchedSetException mse = new MismatchedSetException(null,input);
						recover(mse);
						throw mse;
					}
					}
					break;
				case 3 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1391:9: {...}? ( '\\uD800' .. '\\uDBFF' ) ( '\\uDC00' .. '\\uDFFF' )
					{
					if ( !((Character.isJavaIdentifierPart(Character.toCodePoint((char)input.LA(-1), (char)input.LA(1))))) ) {
						throw new FailedPredicateException(input, "JavaLetterOrDigit", "Character.isJavaIdentifierPart(Character.toCodePoint((char)input.LA(-1), (char)input.LA(1)))");
					}
					if ( (input.LA(1) >= '\uD800' && input.LA(1) <= '\uDBFF') ) {
						input.consume();
					}
					else {
						MismatchedSetException mse = new MismatchedSetException(null,input);
						recover(mse);
						throw mse;
					}
					if ( (input.LA(1) >= '\uDC00' && input.LA(1) <= '\uDFFF') ) {
						input.consume();
					}
					else {
						MismatchedSetException mse = new MismatchedSetException(null,input);
						recover(mse);
						throw mse;
					}
					}
					break;

			}
		}
		finally {
			// do for sure before leaving
		}
	}
529209
public Stylesheet parse() throws ParseException {
        while (tokenizer.more()) {
            if (tokenizer.current().isKeyword(KEYWORD_IMPORT)) {
                // Handle @import
                parseImport();
            } else if (tokenizer.current().isKeyword(KEYWORD_MIXIN)) {
                // Handle @mixin
                Mixin mixin = parseMixin();
                if (mixin.getName() != null) {
                    result.addMixin(mixin);
                }
            } else if (tokenizer.current().isKeyword(KEYWORD_MEDIA)) {
                // Handle @media
                result.addSection(parseSection(true));
            } else if (tokenizer.current().isSpecialIdentifier("$") && tokenizer.next().isSymbol(":")) {
                // Handle variable definition
                parseVariableDeclaration();
            } else {
                // Everything else is a "normal" section  with selectors and attributes
                result.addSection(parseSection(false));
            }
        }

        // Something went wrong? Throw an exception
        if (!tokenizer.getProblemCollector().isEmpty()) {
            throw ParseException.create(tokenizer.getProblemCollector());
        }

        return result;
    }
18919
@Override
  public Query parse() throws SyntaxError {
    if (field == null) {
      throw new SyntaxError("no " + MTAS_CQL_QPARSER_FIELD);
    } else if (cql == null) {
      throw new SyntaxError("no " + MTAS_CQL_QPARSER_QUERY);
    } else {
      MtasSpanQuery q = null;
      MtasSpanQuery iq = null;
      if (ignoreQuery != null) {
        Reader ignoreReader = new BufferedReader(new StringReader(ignoreQuery));
        MtasCQLParser ignoreParser = new MtasCQLParser(ignoreReader);
        try {
          iq = ignoreParser.parse(field, null, null, null, null);
        } catch (mtas.parser.cql.TokenMgrError
            | mtas.parser.cql.ParseException e) {
          throw new SyntaxError(e);
        }
      }
      Reader queryReader = new BufferedReader(new StringReader(cql));
      MtasCQLParser queryParser = new MtasCQLParser(queryReader);
      try {
        q = queryParser.parse(field, defaultPrefix, variables, iq,
            maximumIgnoreLength);
      } catch (mtas.parser.cql.TokenMgrError
          | mtas.parser.cql.ParseException e) {
        throw new SyntaxError(e);
      }
      return q;
    }
  }
1187
@Override
    public ParseResult parse(final Source source) {
        return Util.execute(new ExceptionAction<ParseResult>() {
            @Override
            public ParseResult doAction() throws Throwable {
                logger.fine("Parsing " + source.getSrcInfo());
                final BufferedReader reader = source.createReader();
                try {
                    final ParserImpl impl = factory.create(source.getSrcInfo(),
                            reader);
                    final Doc doc = impl.doc();
                    return new ParseResult(doc, impl.errors());
                } finally {
                    reader.close();
                }
            }
        });
    }
831726
function() {
    var parser, source;
    source = this.source();
    if (source == null) {
      return;
    }
    parser = this.parser();
    if (parser != null) {
      return parser(source);
    } else {
      return source;
    }
  }
316421
protected static OptionParser getParser() {
            OptionParser parser = new OptionParser();
            // help options
            AdminParserUtils.acceptsHelp(parser);
            // required options
            parser.accepts(OPT_HEAD_META_GET_RO, "read-only metadata keys to fetch")
                  .withOptionalArg()
                  .describedAs("ro-meta-key-list")
                  .withValuesSeparatedBy(',')
                  .ofType(String.class);
            AdminParserUtils.acceptsUrl(parser);
            AdminParserUtils.acceptsStoreMultiple(parser);
            // optional options
            AdminParserUtils.acceptsNodeMultiple(parser); // either --node or
                                                          // --all-nodes
            AdminParserUtils.acceptsAllNodes(parser); // either --node or
                                                      // --all-nodes
            return parser;
        }
703509
def syntax(syntax = nil)
      @syntax = syntax if syntax
      syntax_list = []
      if parent
        syntax_list << parent.syntax.to_s.gsub(%r!<[\w\s-]+>!, "").gsub(%r!\[[\w\s-]+\]!, "").strip
      end
      syntax_list << (@syntax || name.to_s)
      syntax_list.join(" ")
    end
1210892
public final EObject ruleNegatedToken() throws RecognitionException {
        EObject current = null;

        Token otherlv_0=null;
        EObject lv_terminal_1_0 = null;



        	enterRule();

        try {
            // InternalXtext.g:3336:2: ( (otherlv_0= '!' ( (lv_terminal_1_0= ruleTerminalTokenElement ) ) ) )
            // InternalXtext.g:3337:2: (otherlv_0= '!' ( (lv_terminal_1_0= ruleTerminalTokenElement ) ) )
            {
            // InternalXtext.g:3337:2: (otherlv_0= '!' ( (lv_terminal_1_0= ruleTerminalTokenElement ) ) )
            // InternalXtext.g:3338:3: otherlv_0= '!' ( (lv_terminal_1_0= ruleTerminalTokenElement ) )
            {
            otherlv_0=(Token)match(input,41,FollowSets000.FOLLOW_47); 

            			newLeafNode(otherlv_0, grammarAccess.getNegatedTokenAccess().getExclamationMarkKeyword_0());
            		
            // InternalXtext.g:3342:3: ( (lv_terminal_1_0= ruleTerminalTokenElement ) )
            // InternalXtext.g:3343:4: (lv_terminal_1_0= ruleTerminalTokenElement )
            {
            // InternalXtext.g:3343:4: (lv_terminal_1_0= ruleTerminalTokenElement )
            // InternalXtext.g:3344:5: lv_terminal_1_0= ruleTerminalTokenElement
            {

            					newCompositeNode(grammarAccess.getNegatedTokenAccess().getTerminalTerminalTokenElementParserRuleCall_1_0());
            				
            pushFollow(FollowSets000.FOLLOW_2);
            lv_terminal_1_0=ruleTerminalTokenElement();

            state._fsp--;


            					if (current==null) {
            						current = createModelElementForParent(grammarAccess.getNegatedTokenRule());
            					}
            					set(
            						current,
            						"terminal",
            						lv_terminal_1_0,
            						"org.eclipse.xtext.Xtext.TerminalTokenElement");
            					afterParserOrEnumRuleCall();
            				

            }


            }


            }


            }


            	leaveRule();

        }

            catch (RecognitionException re) {
                recover(input,re);
                appendSkippedTokens();
            }
        finally {
        }
        return current;
    }
1064755
public ExprTransformer getExprTransfomer() throws TagLibException {
	// Class cls;
	if (exprTransformer != null) return exprTransformer;

	try {
	    exprTransformer = (ExprTransformer) ClassUtil.loadInstance(ELClass.getClazz());
	    // exprTransformer = (ExprTransformer) cls.newInstance();
	}
	catch (Exception e) {
	    throw new TagLibException(e);
	}
	return exprTransformer;
    }
504504
public final TypeParser.type_return type() throws RecognitionException {
        TypeParser.type_return retval = new TypeParser.type_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        TypeParser.typeExpression_return typeExpression1 = null;



        try {
            // org/javaruntype/type/parser/Type.g:101:5: ( typeExpression )
            // org/javaruntype/type/parser/Type.g:101:7: typeExpression
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_typeExpression_in_type160);
            typeExpression1=typeExpression();

            state._fsp--;

            adaptor.addChild(root_0, typeExpression1.getTree());

            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }

            catch (RecognitionException e) {
            	throw e;
            }
        finally {
        }
        return retval;
    }