• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java CodePointCharStream类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: parseUserAgent

import org.antlr.v4.runtime.CodePointCharStream; //导入依赖的package包/类
private UserAgentContext parseUserAgent(UserAgent userAgent) {
    String userAgentString = EvilManualUseragentStringHacks.fixIt(userAgent.getUserAgentString());

    CodePointCharStream input = CharStreams.fromString(userAgentString);
    UserAgentLexer lexer = new UserAgentLexer(input);

    CommonTokenStream tokens = new CommonTokenStream(lexer);

    UserAgentParser parser = new UserAgentParser(tokens);

    if (!verbose) {
        lexer.removeErrorListeners();
        parser.removeErrorListeners();
    }
    lexer.addErrorListener(userAgent);
    parser.addErrorListener(userAgent);

    return parser.userAgent();
}
 
开发者ID:nielsbasjes,项目名称:yauaa,代码行数:20,代码来源:UserAgentTreeFlattener.java


示例2: run

import org.antlr.v4.runtime.CodePointCharStream; //导入依赖的package包/类
private static void run(String expr) throws Exception {
    //构建流CodePointCharStream(4.7版本ANTLRInputStream标记为deprecated)
    CodePointCharStream in = CharStreams.fromString(expr);
    //词法分析
    LionLexer lexer = new LionLexer(in);
    //token流
    CommonTokenStream tokens = new CommonTokenStream(lexer);
    //语法分析器
    LionParser parser = new LionParser(tokens);
    //验证
    parser.prog();
}
 
开发者ID:zhubl,项目名称:planless,代码行数:13,代码来源:Main.java


示例3: buildParser

import org.antlr.v4.runtime.CodePointCharStream; //导入依赖的package包/类
/**
 * Build and return {@link Antlr4OboParser} for a given <code>text</code>.
 *
 * @param text String with the text to parse.
 * @param mode Name of the mode to use.
 * @return {@link Antlr4OboParser}, readily setup for parsing the OBO file.
 */
protected Antlr4OboParser buildParser(String text, String mode) {
  final CodePointCharStream inputStream = CharStreams.fromString(text);
  final OboLexer l = new OboLexer(inputStream);

  for (int i = 0; i < l.getModeNames().length; ++i) {
    if (mode.equals(l.getModeNames()[i])) {
      l.mode(i);
    }
  }

  Antlr4OboParser p = new Antlr4OboParser(new CommonTokenStream(l));

  p.addErrorListener(new BaseErrorListener() {
    @Override
    public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line,
        int charPositionInLine, String msg, RecognitionException e) {
      throw new IllegalStateException("failed to parse at line " + line + " due to " + msg, e);
    }
  });

  p.addErrorListener(new DiagnosticErrorListener());

  p.addParseListener(outerListener);

  return p;
}
 
开发者ID:Phenomics,项目名称:ontolib,代码行数:34,代码来源:Antlr4OboParserTestBase.java


示例4: compile

import org.antlr.v4.runtime.CodePointCharStream; //导入依赖的package包/类
public static Matcher compile(String query) {
  try {
    CodePointCharStream input = CharStreams.fromReader(new StringReader(query));
    ExprLexer lexer = new ExprLexer(input);
    CommonTokenStream tokens = new CommonTokenStream(lexer);
    ExprParser parser = new ExprParser(tokens);
    ParseTree tree = parser.expr();
    Visitor visitor = new Visitor();
    visitor.visit(tree);
    return visitor.expression().normalize();
  } catch (IOException e) {
    throw new RuntimeException(e.getLocalizedMessage(), e);
  }
}
 
开发者ID:before,项目名称:simple-text-search-library,代码行数:15,代码来源:Pattern.java


示例5: testLexingOnNTStrings

import org.antlr.v4.runtime.CodePointCharStream; //导入依赖的package包/类
@Test
public void testLexingOnNTStrings() {
	for (String ntString : NT_STRINGS) {
		CodePointCharStream inputStream = CharStreams.fromString(ntString);
		HGVSLexer l = new HGVSLexer(inputStream);
		l.mode(HGVSLexer.CHANGE_BRANCH);
		l.getAllTokens();
	}
}
 
开发者ID:charite,项目名称:jannovar,代码行数:10,代码来源:AntlrHGVSLexerJustLexTest.java


示例6: testLexingOnLegacyStrings

import org.antlr.v4.runtime.CodePointCharStream; //导入依赖的package包/类
@Test
public void testLexingOnLegacyStrings() {
	for (String ntString : LEGACY_STRINGS) {
		CodePointCharStream inputStream = CharStreams.fromString(ntString);
		HGVSLexer l = new HGVSLexer(inputStream);
		l.mode(HGVSLexer.CHANGE_BRANCH);
		l.getAllTokens();
	}
}
 
开发者ID:charite,项目名称:jannovar,代码行数:10,代码来源:AntlrHGVSLexerJustLexTest.java


示例7: testLexingOnProteinStrings

import org.antlr.v4.runtime.CodePointCharStream; //导入依赖的package包/类
@Test
public void testLexingOnProteinStrings() {
	for (String proteinString : PROTEIN_STRINGS) {
		CodePointCharStream inputStream = CharStreams.fromString(proteinString);
		HGVSLexer l = new HGVSLexer(inputStream);
		l.mode(HGVSLexer.AMINO_ACID_CHANGE);
		l.getAllTokens();
	}
}
 
开发者ID:charite,项目名称:jannovar,代码行数:10,代码来源:AntlrHGVSLexerJustLexTest.java


示例8: testLexingMinimalFile

import org.antlr.v4.runtime.CodePointCharStream; //导入依赖的package包/类
@Test
public void testLexingMinimalFile() {
  final CodePointCharStream inputStream = CharStreams.fromString(MINIMAL_FILE);
  Antlr4OboLexer l = new Antlr4OboLexer(inputStream);
  l.getAllTokens();
}
 
开发者ID:Phenomics,项目名称:ontolib,代码行数:7,代码来源:Antlr4OboLexerSmokeTest.java


示例9: testLexingHeadOfHPO

import org.antlr.v4.runtime.CodePointCharStream; //导入依赖的package包/类
@Test
public void testLexingHeadOfHPO() {
  final CodePointCharStream inputStream = CharStreams.fromString(HEAD_HPO);
  Antlr4OboLexer l = new Antlr4OboLexer(inputStream);
  l.getAllTokens();
}
 
开发者ID:Phenomics,项目名称:ontolib,代码行数:7,代码来源:Antlr4OboLexerSmokeTest.java


示例10: init

import org.antlr.v4.runtime.CodePointCharStream; //导入依赖的package包/类
void init(String newMatchExpression, Matcher newMatcher) {
        this.matcher = newMatcher;
        this.matchExpression = newMatchExpression;
        setVerbose(newMatcher.getVerbose());

        InitErrorListener errorListener = new InitErrorListener();

        CodePointCharStream input = CharStreams.fromString(this.matchExpression);
        UserAgentTreeWalkerLexer lexer = new UserAgentTreeWalkerLexer(input);

        lexer.addErrorListener(errorListener);

        CommonTokenStream tokens = new CommonTokenStream(lexer);
        UserAgentTreeWalkerParser parser = new UserAgentTreeWalkerParser(tokens);

        parser.addErrorListener(errorListener);

//        parser.setTrace(true);
        ParserRuleContext requiredPattern = parseWalkerExpression(parser);

        if (requiredPattern == null) {
            throw new InvalidParserConfigurationException("NO pattern ?!?!?");
        }

        // We couldn't ditch the double quotes around the fixed values in the parsing phase.
        // So we ditch them here. We simply walk the tree and modify some of the tokens.
        new UnQuoteValues().visit(requiredPattern);

        // Now we create an evaluator instance
        evaluator = new TreeExpressionEvaluator(requiredPattern, matcher, verbose);

        // Is a fixed value (i.e. no events will ever be fired)?
        String fixedValue = evaluator.getFixedValue();
        if (fixedValue != null) {
            setFixedValue(fixedValue);
            mustHaveMatches = false;
            matches = new MatchesList(0);
            return; // Not interested in any patterns
        }

        mustHaveMatches = !evaluator.usesIsNull();

        int informs = calculateInformPath("agent", requiredPattern);

        // If this is based on a variable we do not need any matches from the hashmap.
        if (mustHaveMatches && informs == 0) {
            mustHaveMatches = false;
        }

        int listSize = 0;
        if (informs > 0) {
            listSize = 1;
        }
        this.matches = new MatchesList(listSize);
    }
 
开发者ID:nielsbasjes,项目名称:yauaa,代码行数:56,代码来源:MatcherAction.java


示例11: convert

import org.antlr.v4.runtime.CodePointCharStream; //导入依赖的package包/类
public static DateTimeFormatter convert(String strfformat, ZoneId defaultZone) {
    CodePointCharStream input = CharStreams.fromString(strfformat);
    StrfTimeLexer lexer = new StrfTimeLexer(input);

    CommonTokenStream tokens = new CommonTokenStream(lexer);

    StrfTimeParser parser = new StrfTimeParser(tokens);

    lexer.removeErrorListeners();
    parser.removeErrorListeners();

    ParseTreeWalker walker = new ParseTreeWalker(); // create standard walker
    StrfTimeToDateTimeFormatter converter = new StrfTimeToDateTimeFormatter(strfformat, defaultZone);

    lexer.addErrorListener(converter);
    parser.addErrorListener(converter);

    StrfTimeParser.PatternContext pattern = parser.pattern();

    walker.walk(converter, pattern); // initiate walk of tree with listener

    if (converter.hasSyntaxError()) {
        return null;
    }

    return converter.build();
}
 
开发者ID:nielsbasjes,项目名称:logparser,代码行数:28,代码来源:StrfTimeToDateTimeFormatter.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LogLevel类代码示例发布时间:2022-05-22
下一篇:
Java ClientData类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap