| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
The purpose is to be able to parse a R program and then generate the abstract syntax tree (AST).
The parser is generated from a JavaCC grammar, whose productions have been derived from the R grammar file. Later I have tuned those productions to eliminate left recursions and to adapt them to JavaCC.
public static void main(String[] args) {
try {
File file = new File(args[0]); // suppose you are passing the file path as the first argument
InputStream inputStream = new FileInputStream(file);
R rParser = new R(inputStream);
SimpleNode root = rParser.parse();
// Now do something useful with the AST :)
} catch (Exception e) {
System.out.println("Parser error");
e.printStackTrace();
}
}
In my tests I've observed parsing times between 5-10ms per file.
José Antonio Garcel (garcel.developer@gmail.com)
Sept 13 2020
| Back | FazBrowse Home | New Git URL |