Sfoglia il codice sorgente

new example of simplification

develop-theo
Theo Souchon 2 anni fa
parent
commit
c95443c520
11 ha cambiato i file con 21 aggiunte e 35 eliminazioni
  1. +0
    -4
      boot.mc
  2. +2
    -1
      ccmeta.leg
  3. +0
    -0
      tests-parsimony/parsimony-lang/001.c
  4. +0
    -0
      tests-parsimony/parsimony-lang/002.c
  5. +13
    -1
      tests-parsimony/parsimony-lang/003.c
  6. +0
    -0
      tests-parsimony/parsimony-lang/004.c
  7. +2
    -2
      tests-parsimony/parsimony-lang/005.c
  8. +2
    -2
      tests-parsimony/parsimony-lang/006.c
  9. +1
    -1
      tests-parsimony/parsimony-lang/007.c
  10. +0
    -23
      tests-parsimony/parsimony-lang/map.c
  11. +1
    -1
      tests-parsimony/projExample.c

+ 0
- 4
boot.mc Vedi File

@ -1,8 +1,4 @@
@{ @{
createList() {
return {};
}
append(s, e) { append(s, e) {
s[length(s)] = e; s[length(s)] = e;
} }

+ 2
- 1
ccmeta.leg Vedi File

@ -1368,6 +1368,7 @@ integerConstant = < ( hexadecimalConstant
| decimalConstant | decimalConstant
) integerSuffix? ) integerSuffix?
> { $$= new_C_int(yytext); } - > { $$= new_C_int(yytext); } -
| META_AT mvalue
decimalConstant = [1-9][0-9]* decimalConstant = [1-9][0-9]*
@ -2177,7 +2178,7 @@ mstmts = ( s:eval_stmt )* ( META_NIL META_SEMICOLON META_RCB { $$= null
| META_RCB { $$= s } | META_RCB { $$= s }
) )
eval_stmt = s:meta_stmt { $$= eval(globals, s) }
eval_stmt = s:meta_stmt { $$= eval(globals, s) }
meta_stmt = s:meta_block { $$= s } meta_stmt = s:meta_block { $$= s }
| META_SEMICOLON { $$= null } | META_SEMICOLON { $$= null }

tests-parsimony/001.c → tests-parsimony/parsimony-lang/001.c Vedi File


tests-parsimony/002.c → tests-parsimony/parsimony-lang/002.c Vedi File


tests-parsimony/003.c → tests-parsimony/parsimony-lang/003.c Vedi File

@ -11,7 +11,19 @@
int main() int main()
{ {
@{ @{
l = createList();
l = {};
append(l, forLoop);
if (useForLoop) {
append(l, forLoop);
} else {
append(l, whileLoop);
}
l;
};
@{
l = {};
useForLoop = 0;
append(l, forLoop);
if (useForLoop) { if (useForLoop) {
append(l, forLoop); append(l, forLoop);
} else { } else {

tests-parsimony/004.c → tests-parsimony/parsimony-lang/004.c Vedi File


tests-parsimony/005.c → tests-parsimony/parsimony-lang/005.c Vedi File

@ -1,7 +1,7 @@
@{import("boot.mc");} @{import("boot.mc");}
@{ @{
l = createList();
l = {};
append(l, `declaration int a = 5;); append(l, `declaration int a = 5;);
append(l, `declaration int b = 2;); append(l, `declaration int b = 2;);
l; l;
@ -9,7 +9,7 @@
int main() { int main() {
@{ @{
l = createList();
l = {};
a = (`declaration int a = 2;); a = (`declaration int a = 2;);
append(l, `declaration int c = 5;); append(l, `declaration int c = 5;);
b = 5; b = 5;

tests-parsimony/006.c → tests-parsimony/parsimony-lang/006.c Vedi File

@ -1,7 +1,7 @@
@{import("boot.mc");} @{import("boot.mc");}
@{ @{
l = createList();
l = {};
append(l, `declaration int a = 5;); append(l, `declaration int a = 5;);
a = (`declaration int a = 5;); a = (`declaration int a = 5;);
append(l, `declaration int a = 5;); append(l, `declaration int a = 5;);
@ -19,7 +19,7 @@ int main() {
@a; @a;
int b = 0; int b = 0;
@{ @{
l = createList();
l = {};
append(l, `declaration int c = 0;); append(l, `declaration int c = 0;);
x = (`declaration int d = 5;); x = (`declaration int d = 5;);
append(l, x); append(l, x);

tests-parsimony/007.c → tests-parsimony/parsimony-lang/007.c Vedi File

@ -1,7 +1,7 @@
@{import("boot.mc");} @{import("boot.mc");}
@{ @{
l = createList();
l = {};
append(l, `declaration int a = 0;); append(l, `declaration int a = 0;);
a = (`declaration int b = 0;); a = (`declaration int b = 0;);
append(l, a); append(l, a);

tests-parsimony/map.c → tests-parsimony/parsimony-lang/map.c Vedi File

@ -1,28 +1,5 @@
@{import("boot.mc");} @{import("boot.mc");}
@{
toChar(foo) {
"\"type :"+foo+"\"";
}
p2(foo) {
foo * foo;
}
c = ["earth", "sky", "water"];
isSky(x) { x == "sky" }
c = reject(isSky, c);
nil;
}
@{
print(map(p2, [100, 2, 3]));
nil;
}
@{
print(map(toChar, c));
nil;
}
enum foo { A, B, C }; enum foo { A, B, C };
enum oof { A, B, C }; enum oof { A, B, C };

+ 1
- 1
tests-parsimony/projExample.c Vedi File

@ -8,4 +8,4 @@ enum foo { Closed = 0, ReadOnly = 1, WriteOnly = 2 };
nil; nil;
} }
static char stateNames[] = { @(map(idToString, properties.enums.foo.enumList, notToken)) };
static char *stateNames[] = { @(map(idToString, properties.enums.foo.enumList, notToken)) };

Caricamento…
Annulla
Salva