Crates.io | sicompiler |
lib.rs | sicompiler |
version | 1.0.1 |
source | src |
created_at | 2024-01-16 20:06:08.581318 |
updated_at | 2024-02-11 15:45:40.326208 |
description | A basic compiler for SiCoMe programs |
homepage | |
repository | https://github.com/Pacatro/sicompiler.git |
max_upload_size | |
id | 1101939 |
size | 49,404 |
This is a simple project that check for syntax errors in your SiCoMe program.
You can see this project also in Crates.io
You must have Rust installed:
cargo install sicompiler
To use sicompiler you need to have a .txt
file where you write your program and a .rep
file with the valid instructions.
sicompiler --rep <REPERTOIRE_PATH> <INPUT_PATH>
<INPUT_PATH> The input path to compile
<REPERTOIRE_PATH> The repertoire of instructions
[OUTPUT_PATH] The output path to write to [default: out.txt]
-o, --out <OUTPUT_PATH> The output path to write to [default: out.txt]
-r, --rep <REPERTOIRE_PATH> The repertoire of instructions
-h, --help Print help
-V, --version Print version
The result will be an output file with the path you write or a default path in the same directory you are.
0 0003 #Number 1
1 0003 #Number 2
3 0000 #Result
*** This is a
multi-line comment ***
@
6
@
CRA
CRF
ADD 0001
ROR_F_ACC
SFZ
JMP 12 #F!=0
#-----F==0-----
CRA
CRF
ADD 0000
ROL_F_ACC
STA 0004
HALT
#-----F!=0-----
CRA
CRF
ADD 0001
ROL_F_ACC
STA 0004
HALT
0 0003
1 0003
3 0000
@
6
@
CRA
CRF
ADD 0001
ROR_F_ACC
SFZ
JMP 12
CRA
CRF
ADD 0000
ROL_F_ACC
STA 0004
HALT
CRA
CRF
ADD 0001
ROL_F_ACC
STA 0004
HALT
[!IMPORTANT] These standards are subject to updates.
This compiler meets some standars that have been written resently.
The comments in one line will be specified by a #
:
CRA 23 #One line comment
The comments in one line will be specified by ***
at the beginig and another at the end:
CRA 23
***Multi
line
comment***
A program is divided into three clearly differentiated sections, each of them separated by the @
character.
<variables declaration>
@
<start dir>
@
<sentences>
A repertoire
of instructions is the set of instructions that can be in the SiCoMe program.
The structure of a repertoire is like this:
$
<microprogram section> (Not implemented)
$
<valid instructions>
If you want to colaborate and add new features to the project you must do this simples steps.
git clone git@github.com:Pacatro/sicompiler.git
cd sicompiler
cargo build
There are unit tests for the principals structs Tokenizer
and Validator
and only two integration tests.
To execute tests you only need to run the following command:
cargo test
MIT - Created by P4k0.