com.sonar.sslr.impl.Parser.parse()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(87)

本文整理了Java中com.sonar.sslr.impl.Parser.parse()方法的一些代码示例,展示了Parser.parse()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.parse()方法的具体详情如下:
包路径:com.sonar.sslr.impl.Parser
类名称:Parser
方法名:parse

Parser.parse介绍

暂无

代码示例

代码示例来源:origin: org.codehaus.sonar.sslr/sslr-toolkit

public void setSourceCode(File source, Charset charset) {
 this.astNode = configurationModel.getParser().parse(source);
 try {
  this.sourceCode = Files.toString(source, charset);
 } catch (IOException e) {
  Throwables.propagate(e);
 }
}

代码示例来源:origin: org.sonarsource.sslr/sslr-toolkit

public void setSourceCode(File source, Charset charset) {
 this.astNode = configurationModel.getParser().parse(source);
 try {
  this.sourceCode = new String(Files.readAllBytes(Paths.get(source.getPath())), charset);
 } catch (IOException e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: uartois/sonar-golang

public static AstNode parseFile(String filePath) {
final File file = FileUtils.toFile(GoParser.class.getResource(filePath));
if (file == null || !file.exists()) {
  throw new AssertionError("The file \"" + filePath + "\" does not exist.");
}
return P.parse(file);
}

代码示例来源:origin: org.sonarsource.sslr/sslr-testing-harness

public static AstNode parseFile(String filePath) {
 File file = FileUtils.toFile(MiniCParser.class.getResource(filePath));
 if (file == null || !file.exists()) {
  throw new AssertionError("The file \"" + filePath + "\" does not exist.");
 }
 return P.parse(file);
}

代码示例来源:origin: SonarSource/sslr

public void setSourceCode(File source, Charset charset) {
 this.astNode = configurationModel.getParser().parse(source);
 try {
  this.sourceCode = new String(Files.readAllBytes(Paths.get(source.getPath())), charset);
 } catch (IOException e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: org.sonarsource.sslr/sslr-toolkit

public void setSourceCode(String sourceCode) {
 this.astNode = configurationModel.getParser().parse(sourceCode);
 this.sourceCode = sourceCode;
}

代码示例来源:origin: org.codehaus.sonar-plugins.java/java-squid

public static String printFile(String file, String bytecodePath) {
  final Parser p = JavaParser.createParser(Charsets.UTF_8);
  CompilationUnitTree cut = (CompilationUnitTree) p.parse(new File(file));
  List<File> bytecodeFiles = Lists.newArrayList();
  if (!bytecodePath.isEmpty()) {
   bytecodeFiles.add(new File(bytecodePath));
  }
  SemanticModel semanticModel = SemanticModel.createFor(cut, bytecodeFiles);
  return PrinterVisitor.print(cut, semanticModel);
 }
}

代码示例来源:origin: org.codehaus.sonar.sslr/sslr-core

public AstNode parse(File file) {
 try {
  lexer.lex(file);
 } catch (LexerException e) {
  throw new RecognitionException(e);
 }
 return parse(lexer.getTokens());
}

代码示例来源:origin: org.codehaus.sonar-plugins.python/python-checks

private boolean isTextParsedAsCode(String text) {
 try {
  AstNode astNode = parser.parse(text);
  List<AstNode> expressions = astNode.getDescendants(PythonGrammar.EXPRESSION_STMT);
  return astNode.getNumberOfChildren() > 1 && !isSimpleExpression(expressions);
 } catch (Exception e) {
  return false;
 }
}

代码示例来源:origin: SonarSource/sslr

public AstNode parse(String source) {
 try {
  lexer.lex(source);
 } catch (LexerException e) {
  throw new RecognitionException(e);
 }
 return parse(lexer.getTokens());
}

代码示例来源:origin: SonarSource/sslr

public AstNode parse(File file) {
 try {
  lexer.lex(file);
 } catch (LexerException e) {
  throw new RecognitionException(e);
 }
 return parse(lexer.getTokens());
}

代码示例来源:origin: org.sonarsource.sslr/sslr-core

public AstNode parse(String source) {
 try {
  lexer.lex(source);
 } catch (LexerException e) {
  throw new RecognitionException(e);
 }
 return parse(lexer.getTokens());
}

代码示例来源:origin: org.sonarsource.python/python-checks

private static boolean isTextParsedAsCode(String text) {
 try {
  AstNode astNode = parser.parse(text);
  List<AstNode> expressions = astNode.getDescendants(PythonGrammar.EXPRESSION_STMT);
  return astNode.getNumberOfChildren() > 1 && !isSimpleExpression(expressions);
 } catch (Exception e) {
  return false;
 }
}

代码示例来源:origin: org.codehaus.sonar.sslr/sslr-core

public AstNode parse(String source) {
 try {
  lexer.lex(source);
 } catch (LexerException e) {
  throw new RecognitionException(e);
 }
 return parse(lexer.getTokens());
}

代码示例来源:origin: org.sonarsource.sslr/sslr-core

public AstNode parse(File file) {
 try {
  lexer.lex(file);
 } catch (LexerException e) {
  throw new RecognitionException(e);
 }
 return parse(lexer.getTokens());
}

代码示例来源:origin: felipebz/sonar-plsql

public static PlSqlVisitorContext createContext(File file, FormsMetadata metadata) {
 Parser<Grammar> parser = PlSqlParser.create(new PlSqlConfiguration(StandardCharsets.UTF_8));
 TestPlSqlFile pythonFile = new TestPlSqlFile(file);
 AstNode rootTree = parser.parse(pythonFile.content());
 return new PlSqlVisitorContext(rootTree, pythonFile, metadata);
}

代码示例来源:origin: SonarSource/sonar-python

public static PythonVisitorContext createContext(File file) {
 Parser<Grammar> parser = PythonParser.create(new PythonConfiguration(StandardCharsets.UTF_8));
 TestPythonFile pythonFile = new TestPythonFile(file);
 AstNode rootTree = parser.parse(pythonFile.content());
 return new PythonVisitorContext(rootTree, pythonFile);
}

代码示例来源:origin: org.sonarsource.python/python-squid

public static PythonVisitorContext createContext(File file) {
 Parser<Grammar> parser = PythonParser.create(new PythonConfiguration(StandardCharsets.UTF_8));
 TestPythonFile pythonFile = new TestPythonFile(file);
 AstNode rootTree = parser.parse(pythonFile.content());
 return new PythonVisitorContext(rootTree, pythonFile);
}

代码示例来源:origin: sonar-perl/sonar-perl

public static PerlVisitorContext createContext(File file) {
  Parser<Grammar> parser = PerlParser.create(new PerlConfiguration(StandardCharsets.UTF_8));
  TestPerlFile perlFile = new TestPerlFile(file);
  AstNode rootTree = parser.parse(perlFile.content());
  return new PerlVisitorContext(rootTree, perlFile);
}

代码示例来源:origin: sonar-perl/sonar-perl

public static PerlVisitorContext createContext(File file) {
  Parser<Grammar> parser = PerlParser.create(new PerlConfiguration(StandardCharsets.UTF_8));
  TestPerlFile pythonFile = new TestPerlFile(file);
  AstNode rootTree = parser.parse(pythonFile.content());
  return new PerlVisitorContext(rootTree, pythonFile);
}

相关文章

微信公众号

最新文章

更多