Command Line Interface for Unix-like OS and Windows OS that helps you to start a project for the development of your own compiler.
- Directory Structure
- How to install
CLI-compdev
- Get started with
compdev
- Community collaboration
- Changelog
This is the tree chart of the project structure.
|--- /conifg
| |--- /modules
| | |--- /java_cup
| | |--- /jflex
| |
| |--- /win_makefile
| | |--- /Makefile
| |
| |--- /Makefile
| |--- /parser.cup
| |--- /scanner.jflex
|
|--- /unix
| |--- /compdev.sh
|
|--- /windows
|--- /compdev.sh
|--- /compdev.bat
Download CLI-compdev release from here, unzip the getted archive and follow the guide for your OS.
Before starting, you can delete windows
and config/win_makefile
folders.
Move config
folder wherever you want on you MacOS.
I suggest you to create a new directory, e.g. ~/Documents/compdev
, where you can easily put the config
folder.
Be sure you remember where you put this directory because you are going to use its path.
Open unix
folder and edit compdev.sh
file. You have to replace config_path
constant at the beginning of the file with the path to config
folder.
#!/bin/bash
program=compdev
current_dir=.
# path to program config folder
config_path=path/to/config/folder # Edit this, e.g.
# config_path=~/Documents/compdev/config
[...]
Open Terminal application, navigate to the folder where you have compdev.sh
and move the file into /usr/local/bin
system directory with the command below.
sudo mv ./compdev.sh /usr/local/bin/COMPDEV
As /usr/local/bin
directory is owned by user root, you must be an admin and use sudo
to move files there.
The script should be owned by and writable for root, but readable and executable for everyone. The two commands below ensure this:
sudo chown root: /usr/local/bin/COMPDEV
sudo chmod 755 /usr/local/bin/COMPDEV
Be sure you have WSL
installed on your PC before starting install compdev
.
Before starting, you can delete unix
folder and config/Makefile
file.
Move config
folder wherever you want on your Windows.
I suggest you to create a new directory, e.g. C:\Users\Andrea\Documents\compdev
, where you can easily put the config
folder.
Be sure you remember where you put this directory because you are going to use its path.
Open windows
folder and edit compdev.sh
file. You have to replace config_path
constant at the beginning of the file with the path to config
folder.
#!/bin/bash
program=compdev
current_dir=.
# path to program config folder
config_path=path/to/config/folder/in/wsl # Edit this, e.g.
# config_path=/mnt/c/Users/Andrea/Documents/compdev
[...]
Move compdev.sh
and compdev.bat
files into C:\Windows\System32
folder.
You can use compdev
to create a project already formatted and possibly templated for the development of your own compiler.
For now, you can use it just with jflex
and java_cup
, because just their module are loaded into config/module
folder and, morover, templated and non-templated initialization is based on them.
The complete list of command at the moment available is shown below.
You can use compdev init
to initialize your project.
$ compdev init <project_name> [--template]
You should type the name of your new project instead of <project_name>
, but you can also type .
instead of <project_name>
to initialize your project in the current directory where you are running this command.
The default initialization, without --template
option, create the following project structure:
|--- /<project_name>
|--- /build
|--- /modules
|--- /source
| |--- /scanner.jflex
| |--- /parser.cup
|
|--- /Makefile
The --template
option is not mandatory, but, if you use it, the project is initialized with jflex
and java_cup
preloaded into modules
folder. In addition, scanner.flex
, parser.cup
and Makefile
are templated on the same files you can find within config
folder. Here the --template
option project structure:
|--- /<project_name>
|--- /build
|--- /modules
| |--- /java_cup
| |--- /jflex
|
|--- /source
| |--- /scanner.jflex (Templated)
| |--- /parser.cup (Templated)
|
|--- /Makefile (Templated)
If you have already initialized your project, maybe without --template
option, and you want to add a module, you can use the compdev add
command.
$ compdev add <module_name>
At the moment, just jflex
and java_cup
are defined as modules and just them are within the config
folder. So you can use just their name instead of <module_name>
.
For info about commands available, you can run compdev help
.
$ compdev help
I would be very happy if you expanded this project.
You can expand and edit compdev
with whatever you want. You can add new modules and new templates by means editing source code and you can also suggest optimizations or prettier code.
In addition, I also suggest you to watch issues.
I know this program is not perfect but I think it can be a good starting point, so you are welcome!
Here you can check changes between software releases.
- Release of
compdev
for Unix-like OS and Windows. - Just
jflex
andjava_cup
modules support available.