Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ fn main() {
let parser_rules = root_dir.join("src/grammar.rustemo");

if let Err(e) = Settings::new()
.force(false)
.out_dir_actions_root(root_dir.clone())
.out_dir_root(root_dir.clone())
.lexer_type(LexerType::Custom)
.force(false) // Don't force regeneration of files grammar.rs and grammar_actions.rs
.out_dir_actions_root(root_dir.clone()) // Output directory for generated actions
.out_dir_root(root_dir.clone()) // Output directory for generated parser
.lexer_type(LexerType::Custom) // Use our own Lexer
.process_grammar(&parser_rules)
{
eprintln!("Failed to compile rules: {e}");
std::process::exit(1)
}
// Compile Lexer
let lexer_out = root_dir.join("src/lex.rs");
let lexer_src = root_dir.join("src/lex.l");
let lexer_out = root_dir.join("src/lex.rs");

if let Err(e) = rflex::process(lexer_src, Some(lexer_out)) {
for cause in <dyn failure::Fail>::iter_chain(&e) {
eprintln!("{}: {}", cause.name().unwrap_or("Error"), cause);
Expand Down
14 changes: 14 additions & 0 deletions examples/and.lm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
main(){
init {
a, b, c : int
}
a := 1
b := 1
c := 2

if (a > b and c > b)
{
write("a b")
}
}

10 changes: 10 additions & 0 deletions examples/arithmetic.lm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
main(){
init {
x : float
}

x := 27 - c
x := r + 500
x := 34 * 3
x := z / f
}
13 changes: 13 additions & 0 deletions examples/assignements.lm
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
main(){
init {
a : float
b : string
}

a := 99999.99
a := 99.
a := .9999

b := "@sdADaSjfla%dfg"
b := "asldk fh sjf"
}
10 changes: 10 additions & 0 deletions examples/comment.lm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
main(){
init {
a : int
}

#+ Esto es
un comentario +#

a := 1
}
14 changes: 14 additions & 0 deletions examples/convDate.lm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
main(){
init {
a, b, c : int
}

a := 1
b := 10
c := 1900

convDate(11,11,1900)
convDate(a,b,c)
convDate(11,b,1900)
convDate(a,11,c)
}
22 changes: 20 additions & 2 deletions examples/hello_world.lm
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,30 @@ main(){
init
{
x, y : int
a, b, c : float
a, b, c, d : float
var1234 : string
}
a := 33
a := 4+3
b := 9
a := 5.25
b := -5.25
c := "test1234"
d := 1

while(a > b) {
a := 1
}

if(a > b > c > d) {
a := 1
}
else {
b := 1
}

b := 1

if(not b){
a := 1
}
}
17 changes: 17 additions & 0 deletions examples/if.lm
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
main(){
init {
a, b : int
}

a := 1
b := 2

if (a > b)
{
write("aaaaaaaaaaaaaab")
}
else
{
write("a es b")
}
}
5 changes: 5 additions & 0 deletions examples/init.lm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
main(){
init {
a1 : float
}
}
22 changes: 22 additions & 0 deletions examples/isZero.lm
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
main(){
init {
a, b : int
}

a := 1
b := 0

if (isZero(a)) {
write("a es 0")
}
else{
write("a no es 0")
}

if(isZero(b)) {
write("b es 0")
}
else{
write("b no es 0")
}
}
14 changes: 14 additions & 0 deletions examples/not.lm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
main(){
init {
a, b, c : int
}

a := 1
b := 1
c := 2

if (not a > b)
{
write("a b")
}
}
14 changes: 14 additions & 0 deletions examples/or.lm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
main(){
init {
a, b, c : int
}

a := 1
b := 1
c := 2

if (a > b or c > b)
{
write("a b")
}
}
6 changes: 6 additions & 0 deletions examples/read.lm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
main(){
init {
base: string
}
read(base)#+ base es una variable +#
}
14 changes: 14 additions & 0 deletions examples/while.lm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
main(){
init {
a, b : int
}

a := 1
b := 3

while (a > b)
{
write("qwertyuiopasdfghjklzxcvbnm")
a := a + 1
}
}
8 changes: 8 additions & 0 deletions examples/write.lm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
main(){
init {
var1 : int
}

write("ewr") #+ "ewr" es una cte string +#
write(var1) #+ var1 es una variable numerica definida previamente +#
}
Loading