$ANTLR start "PKG"
779301
public final void mPKG() throws RecognitionException {
        try {
            int _type = PKG;
            int _channel = DEFAULT_TOKEN_CHANNEL;
            // com/dyuproject/protostuff/parser/ProtoLexer.g:95:5: ( 'package' )
            // com/dyuproject/protostuff/parser/ProtoLexer.g:95:9: 'package'
            {
            match("package"); 


            }

            state.type = _type;
            state.channel = _channel;
        }
        finally {
        }
    }
306676
public boolean startsWithPackage(String... pkgs) {
        for (String st : pkgs) {
            if (!st.endsWith(".")) st += ".";
            String className = getClassName();
            if (className.startsWith(st)) {
                return true;
            }
        }
        return false;
    }
792934
private String buildIncludeRegExp(String[] scanPaths) {
        String includeRegExp = "";
        for (String path : scanPaths) {
            includeRegExp += path.trim().replace("/", "\\.") + ".*|";
        }
        if (scanPaths.length > 0) {
            // Remove last |
            includeRegExp = includeRegExp.substring(0, includeRegExp.length() - 1);
        }
        return includeRegExp;
    }
108509
def _pkg(jail=None, chroot=None, root=None):
    '''
    
    '''
    ret = ['pkg']
    if jail:
        ret.extend(['-j', jail])
    elif chroot:
        ret.extend(['-c', chroot])
    elif root:
        ret.extend(['-r', root])
    return ret
1042450
public final void mEXPONENT() throws RecognitionException {
		try {
			// hql.g:871:2: ( ( 'e' ) ( '+' | '-' )? ( '0' .. '9' )+ )
			// hql.g:871:4: ( 'e' ) ( '+' | '-' )? ( '0' .. '9' )+
			{
			// hql.g:871:4: ( 'e' )
			// hql.g:871:5: 'e'
			{
			match('e'); if (state.failed) return;
			}

			// hql.g:871:10: ( '+' | '-' )?
			int alt21=2;
			int LA21_0 = input.LA(1);
			if ( (LA21_0=='+'||LA21_0=='-') ) {
				alt21=1;
			}
			switch (alt21) {
				case 1 :
					// hql.g:
					{
					if ( input.LA(1)=='+'||input.LA(1)=='-' ) {
						input.consume();
						state.failed=false;
					}
					else {
						if (state.backtracking>0) {state.failed=true; return;}
						MismatchedSetException mse = new MismatchedSetException(null,input);
						recover(mse);
						throw mse;
					}
					}
					break;

			}

			// hql.g:871:21: ( '0' .. '9' )+
			int cnt22=0;
			loop22:
			while (true) {
				int alt22=2;
				int LA22_0 = input.LA(1);
				if ( ((LA22_0 >= '0' && LA22_0 <= '9')) ) {
					alt22=1;
				}

				switch (alt22) {
				case 1 :
					// hql.g:
					{
					if ( (input.LA(1) >= '0' && input.LA(1) <= '9') ) {
						input.consume();
						state.failed=false;
					}
					else {
						if (state.backtracking>0) {state.failed=true; return;}
						MismatchedSetException mse = new MismatchedSetException(null,input);
						recover(mse);
						throw mse;
					}
					}
					break;

				default :
					if ( cnt22 >= 1 ) break loop22;
					if (state.backtracking>0) {state.failed=true; return;}
					EarlyExitException eee = new EarlyExitException(22, input);
					throw eee;
				}
				cnt22++;
			}

			}

		}
		finally {
			// do for sure before leaving
		}
	}
1288513
private String findPackageName (final String grammar)
  {
    final String packageDeclaration = "package\\s+([^\\s.;]+(\\.[^\\s.;]+)*)\\s*;";
    final Matcher matcher = Pattern.compile (packageDeclaration).matcher (grammar);
    if (matcher.find ())
    {
      return matcher.group (1);
    }
    return "";
  }
252256
Module findModuleFromPackageName(String pkg) {
        int cp = pkg.indexOf(':');
        assert(cp != -1);
        String mod = pkg.substring(0, cp);
        return lookupModule(mod);
    }
1125636
def execute():
    

    arg_parser = ArgumentParser(description='Install helper tool to download the right version of the ANTLR v4 tool jar.')

    arg_parser.add_argument('--version', action='version', version='%(prog)s {version}'.format(version=__version__))

    mode_group = arg_parser.add_mutually_exclusive_group()
    mode_group.add_argument('-f', '--force', action='store_true', default=False,
                            help='force download even if local antlr4.jar already exists')
    mode_group.add_argument('-l', '--lazy', action='store_true', default=False,
                            help='don\'t report an error if local antlr4.jar already exists and don\'t try to download it either')

    args = arg_parser.parse_args()

    install(force=args.force, lazy=args.lazy)
1369359
public final void mSTRING() throws RecognitionException {
        try {
            int _type = STRING;
            int _channel = DEFAULT_TOKEN_CHANNEL;
            // /home/victor/srec/core/src/main/antlr/srec.g:142:2: ( '\"' ( . )* '\"' | '\\'' ( . )* '\\'' )
            int alt6=2;
            int LA6_0 = input.LA(1);

            if ( (LA6_0=='\"') ) {
                alt6=1;
            }
            else if ( (LA6_0=='\'') ) {
                alt6=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 6, 0, input);

                throw nvae;
            }
            switch (alt6) {
                case 1 :
                    // /home/victor/srec/core/src/main/antlr/srec.g:142:4: '\"' ( . )* '\"'
                    {
                    match('\"'); 
                    // /home/victor/srec/core/src/main/antlr/srec.g:142:8: ( . )*
                    loop4:
                    do {
                        int alt4=2;
                        int LA4_0 = input.LA(1);

                        if ( (LA4_0=='\"') ) {
                            alt4=2;
                        }
                        else if ( ((LA4_0>='\u0000' && LA4_0<='!')||(LA4_0>='#' && LA4_0<='\uFFFF')) ) {
                            alt4=1;
                        }


                        switch (alt4) {
                    	case 1 :
                    	    // /home/victor/srec/core/src/main/antlr/srec.g:142:8: .
                    	    {
                    	    matchAny(); 

                    	    }
                    	    break;

                    	default :
                    	    break loop4;
                        }
                    } while (true);

                    match('\"'); 
                    setText(getText().substring(1, getText().length()-1));

                    }
                    break;
                case 2 :
                    // /home/victor/srec/core/src/main/antlr/srec.g:143:4: '\\'' ( . )* '\\''
                    {
                    match('\''); 
                    // /home/victor/srec/core/src/main/antlr/srec.g:143:9: ( . )*
                    loop5:
                    do {
                        int alt5=2;
                        int LA5_0 = input.LA(1);

                        if ( (LA5_0=='\'') ) {
                            alt5=2;
                        }
                        else if ( ((LA5_0>='\u0000' && LA5_0<='&')||(LA5_0>='(' && LA5_0<='\uFFFF')) ) {
                            alt5=1;
                        }


                        switch (alt5) {
                    	case 1 :
                    	    // /home/victor/srec/core/src/main/antlr/srec.g:143:9: .
                    	    {
                    	    matchAny(); 

                    	    }
                    	    break;

                    	default :
                    	    break loop5;
                        }
                    } while (true);

                    match('\''); 
                    setText(getText().substring(1, getText().length()-1));

                    }
                    break;

            }
            state.type = _type;
            state.channel = _channel;
        }
        finally {
        }
    }
599836
private boolean checkPathAndPackage(Path dir, JCTree pkgName) {
        Iterator<String> pathIter = new ParentIterator(dir);
        Iterator<String> pkgIter = new EnclosingPkgIterator(pkgName);
        while (pathIter.hasNext() && pkgIter.hasNext()) {
            if (!pathIter.next().equals(pkgIter.next()))
                return false;
        }
        return !pkgIter.hasNext(); /*&& !pathIter.hasNext() See JDK-8059598 */
    }
1153652
public final void mEXT() throws RecognitionException {
        try {
            int _type = EXT;
            int _channel = DEFAULT_TOKEN_CHANNEL;
            // org/javaruntype/type/parser/Type.g:37:5: ( 'EXT' )
            // org/javaruntype/type/parser/Type.g:37:7: 'EXT'
            {
            match("EXT"); 


            }

            state.type = _type;
            state.channel = _channel;
        }
        finally {
        }
    }
1280901
private static Pattern importStringToPattern(boolean allowModules, String s, Processor p, Log log) {
        String module;
        String pkg;
        int slash = s.indexOf('/');
        if (slash == (-1)) {
            if (s.equals("*")) {
                return MatchingUtils.validImportStringToPattern(s);
            }
            module = allowModules ? ".*/" : "";
            pkg = s;
        } else {
            module = Pattern.quote(s.substring(0, slash + 1));
            pkg = s.substring(slash + 1);
        }
        if (MatchingUtils.isValidImportString(pkg)) {
            return Pattern.compile(module + MatchingUtils.validImportStringToPatternString(pkg));
        } else {
            log.warning("proc.malformed.supported.string", s, p.getClass().getName());
            return noMatches; // won't match any valid identifier
        }
    }
467567
function ( pkg, compiler ) {
			if ( !sys.isEmpty( task.data.depends ) && options.resolveAliases && !sys.isEmpty( pkg.dependAliases ) ) {

				compiler.transform( function ( file ) {
					grunt.verbose.writeln( "Transforming " + file );
					function write( buf ) {
						data += buf;
					}

					var data = '';

					return through( write, function () {
						var __aliases = [];
						sys.each( pkg.dependAliases, function ( al ) {
							if ( data.indexOf( "'" + al + "'" ) !== -1 || data.indexOf( '"' + al + '"' ) !== -1 ) {
								__aliases.push( "'" + al + "' : '" + al + "'" );

								data = data.replace( new RegExp( "'" + al + "'", "g" ), "__aliases['" + al + "']" );
								data = data.replace( new RegExp( '"' + al + '"', "g" ), "__aliases['" + al + "']" );
							}
						} );
						if ( !sys.isEmpty( __aliases ) ) {
							var aliasDefinition = "var __aliases = {" + __aliases.join( ",\n" ) + "};\n";

							data = aliasDefinition + data;

						}
						this.queue( data );
						this.queue( null );
					} );

				} );
			}
		}
290445
public UnitDescr unitStatement( PackageDescrBuilder pkg ) throws RecognitionException {
        UnitDescrBuilder imp = helper.start( pkg,
                                             UnitDescrBuilder.class,
                                             null );

        try {
            // import
            match(input,
                  DRL6Lexer.ID,
                  DroolsSoftKeywords.UNIT,
                  null,
                  DroolsEditorType.KEYWORD);
            if (state.failed) return null;

            // qualifiedIdentifier
            String target = qualifiedIdentifier();
            if (state.failed)
                return null;

            if (state.backtracking == 0) {
                imp.target( target );
            }

            if (input.LA(1) == DRL6Lexer.SEMICOLON) {
                match(input,
                      DRL6Lexer.SEMICOLON,
                      null,
                      null,
                      DroolsEditorType.SYMBOL);
                if (state.failed) return null;
            }
            return (imp != null) ? imp.getDescr() : null;
        } finally {
            helper.end(ImportDescrBuilder.class,
                       imp);
        }
    }
330135
public static String canonicalClassName(Class<?> c, Package pkg) {
    String name = c.getName();
    if(pkg != null) {
      final String pkgname = pkg.getName();
      if(name.length() > pkgname.length() && name.startsWith(pkgname) && name.charAt(pkgname.length()) == '.') {
        name = name.substring(pkgname.length() + 1);
      }
    }
    if(name.endsWith(ELKIServiceRegistry.FACTORY_POSTFIX)) {
      name = name.substring(0, name.length() - ELKIServiceRegistry.FACTORY_POSTFIX.length());
    }
    return name;
  }
636300
def main(args=sys.argv[1:]):
    """"""
    parser = argparse.ArgumentParser()
    parser.add_argument("filename", nargs=1)
    parser.add_argument("--granule-id", dest="granule_id",
        help=(
            "Optional. Specify a granule to export metadata from."
        )
    )
    parser.add_argument("--single-granule", dest="single_granule",
        action="store_true", default=False,
        help=(
            "When only one granule is contained in the package, include product "
            "metadata from this one granule. Fails when more than one granule "
            "is contained."
        )
    )
    parser.add_argument("--out-file", "-f", dest="out_file",
        help=(
            "Specify an output file to write the metadata to. By default, the "
            "XML is printed on stdout."
        )
    )
    parser.add_argument("--resolution", "-r", dest="resolution", default="10",
        help=(
            "Only produce metadata for bands of this resolution (in meters). "
            "Default is 10."
        )
    )

    parsed = parser.parse_args(args)

    try:
        safe_pkg = s2reader.open(parsed.filename[0])
    except IOError, e:
        parser.error('Could not open SAFE package. Error was "%s"' % e)

    granules = safe_pkg.granules

    granule = None
    if parsed.granule_id:
        granule_dict = dict(
            (granule.granule_identifier, granule) for granule in granules
        )
        try:
            granule = granule_dict[parsed.granule_id]
        except KeyError:
            parser.error('No such granule %r' % parsed.granule_id)

    elif parsed.single_granule:
        if len(granules) > 1:
            parser.error('Package contains more than one granule.')

        granule = granules[0]

    params = _get_product_template_params(safe_pkg, parsed.resolution)

    if granule:
        params.update(_get_granule_template_params(granule, parsed.resolution))
        xml_string = EOOM_TEMPLATE_GRANULE.format(**params)
    else:
        xml_string = EOOM_TEMPLATE_PRODUCT.format(**params)

    if parsed.out_file:
        with open(parsed.out_file, "w") as f:
            f.write(xml_string)
    else:
        print(xml_string)
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); }

		}
	}