当前位置: 首页>>代码示例>>Java>>正文


Java ANTLRReaderStream类代码示例

本文整理汇总了Java中org.antlr.runtime.ANTLRReaderStream的典型用法代码示例。如果您正苦于以下问题:Java ANTLRReaderStream类的具体用法?Java ANTLRReaderStream怎么用?Java ANTLRReaderStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ANTLRReaderStream类属于org.antlr.runtime包,在下文中一共展示了ANTLRReaderStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseTree

import org.antlr.runtime.ANTLRReaderStream; //导入依赖的package包/类
static Tree parseTree(CharSource input)
        throws IOException
{
    try (Reader reader = input.openStream()) {
        ThriftLexer lexer = new ThriftLexer(new ANTLRReaderStream(reader));
        ThriftParser parser = new ThriftParser(new CommonTokenStream(lexer));
        try {
            Tree tree = (Tree) parser.document().getTree();
            if (parser.getNumberOfSyntaxErrors() > 0) {
                throw new IllegalArgumentException("syntax error");
            }
            return tree;
        }
        catch (RecognitionException e) {
            throw new IllegalArgumentException(e);
        }
    }
}
 
开发者ID:l3ug1m,项目名称:thrift-java-compiler,代码行数:19,代码来源:ThriftIdlParser.java

示例2: getKoopaAST

import org.antlr.runtime.ANTLRReaderStream; //导入依赖的package包/类
private static CommonTree getKoopaAST(String filename)
		throws FileNotFoundException, IOException, RecognitionException {
	System.out.println("Reading " + filename);
	Reader reader = new FileReader(filename);

	KGLexer lexer = new KGLexer(new ANTLRReaderStream(reader));

	CommonTokenStream tokens = new CommonTokenStream(lexer);

	KGParser parser = new KGParser(tokens);

	KGParser.koopa_return koopa = parser.koopa();

	CommonTree ast = (CommonTree) koopa.getTree();
	if (SHOW_AST) {
		new ASTFrame("KG", ast).setVisible(true);
	}
	return ast;
}
 
开发者ID:goblindegook,项目名称:Koopa,代码行数:20,代码来源:KGToANTLR.java

示例3: doParse

import org.antlr.runtime.ANTLRReaderStream; //导入依赖的package包/类
@Override
public IParseResult doParse(Reader reader) {
	try {
		return parse(getDefaultRuleName(), new ANTLRReaderStream(reader));
	} catch (IOException e) {
		throw new WrappedException(e);
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:9,代码来源:AbstractAntlrParser.java

示例4: parse

import org.antlr.runtime.ANTLRReaderStream; //导入依赖的package包/类
@Override
public IParseResult parse(ParserRule rule, Reader reader) {
	try {
		IParseResult parseResult = parse(rule.getName(), new ANTLRReaderStream(reader));
		return parseResult;
	} catch (IOException e) {
		throw new WrappedException(e);
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:10,代码来源:AbstractAntlrParser.java

示例5: getCharStream

import org.antlr.runtime.ANTLRReaderStream; //导入依赖的package包/类
protected CharStream getCharStream(final Reader reader) {
  try {
    return new ANTLRReaderStream(reader);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:8,代码来源:AbstractTokenSourceProvider.java

示例6: process

import org.antlr.runtime.ANTLRReaderStream; //导入依赖的package包/类
/**
 * The only method that should be called to initiate the process
 * @param is	The input stream from where to get the data
 * @param os 	The output stream to write the processed fragment/document to
 * @param htmlFilter	An interface called during the processing of the document. Can be used to modify elements
 * @param convertIntoValidXML	Converts the output into valid XML for XSL processing for example
 */
public static void process( Reader reader, Writer writer, IHTMLFilter htmlFilter, boolean convertIntoValidXML ) throws HandlingException {
	try {
		// Open a char stream input for the document
		ANTLRStringStream input = new ANTLRReaderStream( reader );
		
		// Start lexing the input
		htmlLexerLexer lex = new htmlLexerLexer(input);

		// Tokenstream for the parser.
		CommonTokenStream tokens = new CommonTokenStream(lex);
		htmlParserParser parser = new htmlParserParser(tokens);
		htmlParserParser.document_return root = parser.document();

		// Set up the tree parser
		CommonTreeNodeStream nodes = new CommonTreeNodeStream((Tree)root.getTree());
		htmlTreeParser walker = new htmlTreeParser(nodes);

		// Initialize data structures
		topNode = new ThreadLocal();
		currentNode = new ThreadLocal();
		attrNode = new ThreadLocal();

		// Walk in the entire document using the tree parser.
		walker.document();
		
		// Get the top node
		TagNode top = (TagNode)topNode.get();
		
		// Write the clean document out.
		top.writeAll( writer, htmlFilter, convertIntoValidXML, false );
	} catch ( IOException ioe ) {
		throw new HandlingException( "Could not parse document" );
	} catch ( RecognitionException re ) {
		throw new HandlingException( "Could not parse document" );
	}
}
 
开发者ID:lcgg110,项目名称:xssprotect,代码行数:44,代码来源:HTMLParser.java

示例7: getAntlrStream

import org.antlr.runtime.ANTLRReaderStream; //导入依赖的package包/类
private static ANTLRReaderStream getAntlrStream(String code) {
  try {
    return new ANTLRReaderStream(new StringReader(code));
  } catch (IOException e) {
    // Will never happen, since it's a StringReader...
    return null;
  }
}
 
开发者ID:Sable,项目名称:mclab-core,代码行数:9,代码来源:TokenUtil.java

示例8: stringStream

import org.antlr.runtime.ANTLRReaderStream; //导入依赖的package包/类
public static CSSInputStream stringStream(String source) throws IOException {
	CSSInputStream stream = new CSSInputStream();
	
	stream.rawData = source;
	stream.encoding = Charset.defaultCharset().name();
	
	BufferedReader br = new BufferedReader(
			new InputStreamReader(new ByteArrayInputStream(source.getBytes()), stream.encoding));
	stream.input = new ANTLRReaderStream(br);
	
	return stream;
}
 
开发者ID:mantlik,项目名称:swingbox-javahelp-viewer,代码行数:13,代码来源:CSSInputStream.java

示例9: tokenStartPositions

import org.antlr.runtime.ANTLRReaderStream; //导入依赖的package包/类
private List<Integer> tokenStartPositions() throws IOException {
    List<Integer> res = new ArrayList<Integer>();
    ANTLRReaderStream input = new ANTLRInputStream(new FileInputStream(masterFile));
    v4Lexer lexer = new v4Lexer(input);
    Token t = lexer.nextToken();
    while (t.getType() != Token.EOF) {
        if (t.getChannel() != Token.HIDDEN_CHANNEL) {
            res.add(lexer.getCharIndex());
        }
        t = lexer.nextToken();
    }
    return res;
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:14,代码来源:VSGC1117Test.java

示例10: newParser

import org.antlr.runtime.ANTLRReaderStream; //导入依赖的package包/类
public static ObjCppParser newParser(String s) throws IOException {
    Result result = new Result(new JNAeratorConfig(), null, null);
    ObjCppParser parser = new ObjCppParser(new CommonTokenStream(new ObjCppLexer(
            new ANTLRReaderStream(new StringReader(s)))) // , new DummyDebugEventListener()
            );
    parser.objCParserHelper = result.typeConverter;
    return parser;
}
 
开发者ID:nativelibs4java,项目名称:JNAerator,代码行数:9,代码来源:JNAerator.java

示例11: newObjCDemangler

import org.antlr.runtime.ANTLRReaderStream; //导入依赖的package包/类
static ObjCDemanglingParser newObjCDemangler(String s, final boolean verbose) throws IOException {
        return new ObjCDemanglingParser(
                new CommonTokenStream(
                new ObjCDemanglingLexer(
                new ANTLRReaderStream(new StringReader(s)))) //				, new DummyDebugEventListener()
                ) {
            @Override
            public void reportError(RecognitionException arg0) {
                if (verbose) {
//					System.err.println(arg0 + " (next = '" + next() + "')");
                    super.reportError(arg0);
                }
            }
        };
    }
 
开发者ID:nativelibs4java,项目名称:JNAerator,代码行数:16,代码来源:BridgeSupportParser.java

示例12: newObjCppParser

import org.antlr.runtime.ANTLRReaderStream; //导入依赖的package包/类
protected ObjCppParser newObjCppParser(TypeConversion typeConverter, String s, final boolean verbose, final PrintStream errorOut) throws IOException {
        ObjCppParser parser = new ObjCppParser(
                new CommonTokenStream(
                new ObjCppLexer(
                new ANTLRReaderStream(new StringReader(s)))) //		    , new DummyDebugEventListener()
                ) {
            @Override
            public void emitErrorMessage(String msg) {
                if (errorOut == null) {
//                    if (verbose)
//                        super.emitErrorMessage(msg);
                } else {
                    errorOut.println(msg);
                }
            }

            @Override
            public void reportError(RecognitionException arg0) {
                if (verbose) {
                    super.reportError(arg0);
                }
            }
        };
        parser.setupScopes();
        parser.objCParserHelper = typeConverter;

        return parser;
    }
 
开发者ID:nativelibs4java,项目名称:JNAerator,代码行数:29,代码来源:JNAeratorParser.java

示例13: newParser

import org.antlr.runtime.ANTLRReaderStream; //导入依赖的package包/类
public static ObjCppParser newParser(String s) throws IOException {
	Result result = new Result(new JNAeratorConfig(), null, null);
	ObjCppParser parser = new ObjCppParser(new CommonTokenStream(new ObjCppLexer(
			new ANTLRReaderStream(new StringReader(s))))
	// , new DummyDebugEventListener()
	);
	parser.objCParserHelper = result.typeConverter;
	return parser;
}
 
开发者ID:nativelibs4java,项目名称:JNAerator,代码行数:10,代码来源:ObjCppParsingTest.java

示例14: extractTagsFromString

import org.antlr.runtime.ANTLRReaderStream; //导入依赖的package包/类
private List<String> extractTagsFromString(String in) throws IOException {
    try (Reader stringToInputStream = new StringReader(in)) {
        TagLexer tagsLexer = new TagLexer(new ANTLRReaderStream(stringToInputStream));
        CommonTokenStream tokens = new CommonTokenStream(tagsLexer);
        TagParser pa = new TagParser(tokens);
        return pa.getParsedTags();
    }
}
 
开发者ID:joshlong,项目名称:ws.tagit,代码行数:9,代码来源:TagTemplate.java

示例15: getTokenStream

import org.antlr.runtime.ANTLRReaderStream; //导入依赖的package包/类
public static CommonTokenStream getTokenStream(java.io.Reader reader)
	throws java.io.IOException
{
	SExpressionLexer lexer
		= new SExpressionLexer(new ANTLRReaderStream(reader));
	return new CommonTokenStream(lexer);
}
 
开发者ID:BrainTech,项目名称:jsignalml,代码行数:8,代码来源:Processor.java


注:本文中的org.antlr.runtime.ANTLRReaderStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。