There was a tool called JavaCC (Java Compiler Compiler) that can be used with Java.
A tool for parsing (recursive descent) and lexical analysis. If you write your own parsing and lexical analysis definition files, a Java parser will be generated for you.
Eclipse is used as a comprehensive development environment. A JavaCC plugin for Eclipse (a set for each compiler) is provided. Please install the plug-in by specifying the following from "help"-> "install new software". JavaCC - http://eclipse-javacc.sourceforge.net/
Create a new Java Project of your choice.
Create a new template file.
Select jjt and the package completes by default
Replace <? Parser_name?>
With MyNewPerser all at once.
When saved, the parser is automatically generated as shown below.
If it is not automatically generated, right-click the jjt file and execute "Compile with javacc".
Since main is attached to the MyNewParser class, it can be executed as it is.
(Displays a simple formula syntax tree)
Make a language! (Making a simple calculator ①) followed by.
Recommended Posts