Skip to content

Commit 0215e7c

Browse files
Fixed make keyword with multiline replace and single line take
1 parent 024d4bf commit 0215e7c

2 files changed

Lines changed: 24 additions & 14 deletions

File tree

EZCode/Parser.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -904,13 +904,16 @@ it after loop is finshed. This allows all values to be evaluated and stored befo
904904
else if (parts[i].ToString() == "make")
905905
{
906906
// syntax,
907-
// make A => B
908-
// make A {VAR} A => B {VAR} B
909-
/* make {
910-
* A
907+
/*
908+
* make A => B
909+
*
910+
* make A {VAR} A => B {VAR} B
911+
*
912+
* make {
913+
* A {VAR}
911914
* A
912915
* } => {
913-
* B
916+
* B {VAR}
914917
* B
915918
* }
916919
*/
@@ -983,6 +986,7 @@ it after loop is finshed. This allows all values to be evaluated and stored befo
983986
next++;
984987
// set replace to the multi line
985988
replace = multiLineTake.ToString();
989+
replaceMulti = replace.Split('\n').Select(x => x.Trim()).ToArray()[0];
986990
}
987991
// create new array for all of the take lines
988992
string[] takeLines = take.Split("\n").Select(x => x.Trim()).Where(y => y != "").ToArray();

TestEnv/Code.ezcode

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,28 @@ make ^bool {NAME} {VALUE} => bool {NAME} new : {VALUE}
55
make ^str {NAME} {VALUE} => str {NAME} new : {VALUE}
66
make ^global {TYPE} {NAME} {VALUE} => global {TYPE} {NAME} new : {VALUE}
77

8-
/*make for {TYPE} {I1} {VAL}, {I2} {COMP} {NUM}, {I3} {METHOD} {ADD} \{ => {
9-
{TYPE} {I1} new : {VAL}
8+
make {
9+
^for {TYPE} {I1} {VAL}, {I2} {COMP} {NUM}, {I3} {METHOD} {ADD}
10+
\{
11+
} => {
12+
{TYPE} {I1} new : ({VAL} - 1)
13+
loop {I2} {COMP} {NUM} \{
14+
{I3} {METHOD} {ADD}
15+
}
16+
make ^for {TYPE} {I1} {VAL}, {I2} {COMP} {NUM}, {I3} {METHOD} {ADD} \{ => {
17+
{TYPE} {I1} new : ({VAL} - 1)
1018
loop {I2} {COMP} {NUM} \{
1119
{I3} {METHOD} {ADD}
1220
}
13-
for var i 0, i < test, i + 1 {
14-
print '(i + 1)'\; '(i * i * i)'
15-
}*/
1621

1722
global var test 20
1823

1924
method Start {
20-
var i 0
21-
loop i < test {
25+
26+
for var i 0, i < test, i + 1 {
2227
print '(i + 1)'\; '(i * i * i)'
23-
i + 1
2428
}
29+
2530
bool result (test < 50)
2631
if result {
2732
print result
@@ -30,5 +35,6 @@ method Start {
3035
}
3136

3237
method other {
33-
print other
38+
test * 150
39+
print other 'test'
3440
}

0 commit comments

Comments
 (0)