| <!-- | |
| Copyright 2019 Alain Dargelas | |
| Licensed under the Apache License, Version 2.0 (the "License"); | |
| you may not use this file except in compliance with the License. | |
| You may obtain a copy of the License at | |
| http://www.apache.org/licenses/LICENSE-2.0 | |
| Unless required by applicable law or agreed to in writing, software | |
| distributed under the License is distributed on an "AS IS" BASIS, | |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| See the License for the specific language governing permissions and | |
| limitations under the License. | |
| --> | |
| <!-- Ant build script for the grammars --> | |
| <project name="SV Antlr Grammar" default="compile_cpp" basedir="."> | |
| <description> | |
| System Verilog Antlr Grammar build | |
| </description> | |
| <!-- set global properties for this build --> | |
| <property name="antlr_tool_location" | |
| value="../antlr4/antlr4-4.7.2/tool/target/antlr4-4.7.2-complete.jar"/> | |
| <property name="antlr_tool_target" value="org.antlr.v4.Tool"/> | |
| <property name="antlr_test_rig" value="org.antlr.v4.gui.TestRig"/> | |
| <property name="sv_parser_grammar" value="SV3_1a"/> | |
| <property name="sv_preproc_grammar" value="SV3_1aPp"/> | |
| <property name="sv_splitter_grammar" value="SV3_1aSplitter"/> | |
| <property name="sv_parser_top_rule" value="top_level_rule"/> | |
| <property name="sv_splitter_top_rule" value="source_text"/> | |
| <property name="sv_preproc_top_rule" value="source_text"/> | |
| <property name="antlr_tool_cpp_options" value="-Dlanguage=Cpp"/> | |
| <target name="init"> | |
| <!-- Create the time stamp --> | |
| <tstamp/> | |
| <!-- Delete the generated files: *.cpp, *.h, *.tokens --> | |
| <delete> | |
| <fileset dir="." includes="*.cpp *.h *.tokens"/> | |
| </delete> | |
| </target> | |
| <target name="compile_cpp" depends="init" | |
| description="compile the Grammar files for C++"> | |
| <!-- Compile the G4 files for C++, only generates C++ files --> | |
| <echo>Antlr Compile SV3_1aPpLexer.g4 SV3_1aPpParser.g4 SV3_1aSplitterLexer.g4 SV3_1aSplitterParser.g4 </echo> | |
| <java classpath="${antlr_tool_location}" classname="${antlr_tool_target}" fork="true" maxmemory="4096m" > | |
| <arg line="${antlr_tool_cpp_options} SV3_1aPpLexer.g4 SV3_1aPpParser.g4 SV3_1aSplitterLexer.g4 SV3_1aSplitterParser.g4" /> | |
| </java> | |
| </target> | |
| <target name="compile_java" depends="init" | |
| description="Compile the Grammar files for Java for Testing purposes"> | |
| <!-- Compile the G4 files for Java target--> | |
| <echo>Antlr Compile SV3_1aPpLexer.g4 SV3_1aPpParser.g4 SV3_1aSplitterLexer.g4 SV3_1aSplitterParser.g4</echo> | |
| <java classpath="${antlr_tool_location}" classname="${antlr_tool_target}"> | |
| <arg line=" SV3_1aPpLexer.g4 SV3_1aPpParser.g4 SV3_1aSplitterLexer.g4 SV3_1aSplitterParser.g4" /> | |
| </java> | |
| </target> | |
| <target name="compile_full_cpp" depends="init" | |
| description="compile the Grammar files for C++"> | |
| <!-- Compile the G4 files for C++, only generates C++ files --> | |
| <echo>Antlr Compile SV3_1aLexer.g4 SV3_1aParser.g4 SV3_1aPpLexer.g4 SV3_1aPpParser.g4 SV3_1aSplitterLexer.g4 SV3_1aSplitterParser.g4 </echo> | |
| <java classpath="${antlr_tool_location}" classname="${antlr_tool_target}" fork="true" maxmemory="4096m" > | |
| <arg line="${antlr_tool_cpp_options} SV3_1aLexer.g4 SV3_1aParser.g4 SV3_1aPpLexer.g4 SV3_1aPpParser.g4 SV3_1aSplitterLexer.g4 SV3_1aSplitterParser.g4" /> | |
| </java> | |
| </target> | |
| <target name="compile_full_java" depends="init" | |
| description="Compile the Grammar files for Java for Testing purposes"> | |
| <!-- Compile the G4 files for Java target--> | |
| <echo>Antlr Compile SV3_1aLexer.g4 SV3_1aParser.g4 SV3_1aPpLexer.g4 SV3_1aPpParser.g4 SV3_1aSplitterLexer.g4 SV3_1aSplitterParser.g4</echo> | |
| <java classpath="${antlr_tool_location}" classname="${antlr_tool_target}"> | |
| <arg line=" SV3_1aLexer.g4 SV3_1aParser.g4 SV3_1aPpLexer.g4 SV3_1aPpParser.g4 SV3_1aSplitterLexer.g4 SV3_1aSplitterParser.g4" /> | |
| </java> | |
| </target> | |
| <target name="javac" description="Compile all Java files"> | |
| <!-- Java compile all .java files into .class --> | |
| <echo>Compile all Java files</echo> | |
| <mkdir dir="build"/> | |
| <javac classpath="${antlr_tool_location}" srcdir="." | |
| destdir="build" debug="true" includeantruntime="false" | |
| fork="true"/> | |
| </target> | |
| <target name="copy_cpp"> | |
| <!-- Copy generated files to Project area --> | |
| <copy todir="../SVIncCompil/parser/"> | |
| <fileset dir="." includes="*.cpp *.h *.tokens"/> | |
| </copy> | |
| </target> | |
| <target name="copy_pp_cpp"> | |
| <!-- Copy generated files to Project area --> | |
| <copy todir="../SVIncCompil/parser/"> | |
| <fileset dir="." includes="*Pp*.cpp *Pp*.h *Pp*.tokens"/> | |
| </copy> | |
| </target> | |
| <target name="copy_lib_cpp"> | |
| <!-- Copy generated files to Project area --> | |
| <copy todir="../SVIncCompil/parser/"> | |
| <fileset dir="." includes="*Lib*.cpp *Lib*.h *Lib*.tokens"/> | |
| </copy> | |
| </target> | |
| <target name="clean" | |
| description="clean up"> | |
| <!-- Delete the generated files: *.cpp, *.h, *.tokens *.java --> | |
| <delete> | |
| <fileset dir="." includes="*.cpp *.h *.tokens *.java"/> | |
| <fileset dir="build"/> | |
| </delete> | |
| </target> | |
| <target name="test_tokens"> | |
| <java classpath="${antlr_tool_location}:build" classname="${antlr_test_rig}"> | |
| <arg line="${sv_parser_grammar} ${sv_parser_top_rule} -tokens" /> | |
| </java> | |
| </target> | |
| <target name="test_gui"> | |
| <java classpath="${antlr_tool_location}:build" classname="${antlr_test_rig}"> | |
| <arg line="${sv_parser_grammar} ${sv_parser_top_rule} -gui" /> | |
| </java> | |
| </target> | |
| <target name="test_tree"> | |
| <java classpath="${antlr_tool_location}:build" classname="${antlr_test_rig}"> | |
| <arg line="${sv_parser_grammar} ${sv_parser_top_rule} -tree" /> | |
| </java> | |
| </target> | |
| <target name="test_pp_tokens"> | |
| <java classpath="${antlr_tool_location}:build" classname="${antlr_test_rig}"> | |
| <arg line="${sv_preproc_grammar} ${sv_preproc_top_rule} -tokens" /> | |
| </java> | |
| </target> | |
| <target name="test_pp_gui"> | |
| <java classpath="${antlr_tool_location}:build" classname="${antlr_test_rig}"> | |
| <arg line="${sv_preproc_grammar} ${sv_preproc_top_rule} -gui" /> | |
| </java> | |
| </target> | |
| <target name="test_pp_tree"> | |
| <java classpath="${antlr_tool_location}:build" classname="${antlr_test_rig}"> | |
| <arg line="${sv_preproc_grammar} ${sv_preproc_top_rule} -tree" /> | |
| </java> | |
| </target> | |
| <target name="test_split_tokens"> | |
| <java classpath="${antlr_tool_location}:build" classname="${antlr_test_rig}"> | |
| <arg line="${sv_splitter_grammar} ${sv_splitter_top_rule} -tokens" /> | |
| </java> | |
| </target> | |
| <target name="test_split_gui"> | |
| <java classpath="${antlr_tool_location}:build" classname="${antlr_test_rig}"> | |
| <arg line="${sv_splitter_grammar} ${sv_splitter_top_rule} -gui" /> | |
| </java> | |
| </target> | |
| <target name="test_split_tree"> | |
| <java classpath="${antlr_tool_location}:build" classname="${antlr_test_rig}"> | |
| <arg line="${sv_splitter_grammar} ${sv_splitter_top_rule} -tree" /> | |
| </java> | |
| </target> | |
| </project> |