Ver código fonte

test fix + add rules number

develop-theo
Theo Souchon 2 anos atrás
pai
commit
bbfc2b5a03
35 arquivos alterados com 178 adições e 125 exclusões
  1. +15
    -0
      src/c
  2. +98
    -52
      src/ccmeta.leg
  3. +2
    -0
      src/object.c
  4. +1
    -1
      src/parsimonyLibrary/boot.mc
  5. +13
    -13
      src/parsimonyLibrary/dynamicObjectExtDecl.mc
  6. +12
    -12
      src/parsimonyLibrary/dynamicObjectParsFrom.mc
  7. +4
    -0
      src/tests/tests-c/00104.c
  8. +2
    -0
      src/tests/tests-c/00187.c
  9. +3
    -0
      src/tests/tests-c/00189.c
  10. +2
    -0
      src/tests/tests-c/00220.c
  11. +0
    -0
      src/tests/tests-cpp/00062.c
  12. +0
    -0
      src/tests/tests-cpp/00063.c
  13. +0
    -0
      src/tests/tests-cpp/00066.c
  14. +0
    -0
      src/tests/tests-cpp/00067.c
  15. +0
    -0
      src/tests/tests-cpp/00068.c
  16. +0
    -0
      src/tests/tests-cpp/00069.c
  17. +0
    -0
      src/tests/tests-cpp/00070.c
  18. +0
    -0
      src/tests/tests-cpp/00071.c
  19. +0
    -0
      src/tests/tests-cpp/00074.c
  20. +0
    -0
      src/tests/tests-cpp/00115.c
  21. +0
    -0
      src/tests/tests-cpp/00122.c
  22. +0
    -0
      src/tests/tests-cpp/00137.c
  23. +0
    -0
      src/tests/tests-cpp/00162.c
  24. +0
    -0
      src/tests/tests-cpp/00200.c
  25. +0
    -0
      src/tests/tests-cpp/00202.c
  26. +0
    -0
      src/tests/tests-cpp/00210.c
  27. +0
    -0
      src/tests/tests-cpp/00219.c
  28. +0
    -0
      src/tests/tests-err/00204.c
  29. +2
    -12
      src/tests/tests-parsimony/008.c
  30. +8
    -1
      src/tests/tests-parsimony/009
  31. +12
    -7
      src/tests/tests-parsimony/009.c
  32. +0
    -8
      src/tests/tests-parsimony/010
  33. +0
    -15
      src/tests/tests-parsimony/010.c
  34. +2
    -2
      src/tests/tests-parsimony/realObjectED
  35. +2
    -2
      src/tests/tests-parsimony/realObjectPF

+ 15
- 0
src/c Ver arquivo

@ -0,0 +1,15 @@
ccmeta.c: oop idKeys = map_keys(keys);
ccmeta.c:oop prim_keys(oop scope, oop params)
ccmeta.c: if (is(Map, arg)) return map_keys(arg);
ccmeta.c:oop prim_all_keys(oop scope, oop params)
ccmeta.c: println(map_keys(yylval));
ccmeta.c: map_set(globals, intern("keys" ), makeFunction(prim_keys, intern("keys" ), null, null, globals, null));
ccmeta.c: map_set(globals, intern("_keys" ), makeFunction(prim_all_keys, intern("_keys" ), null, null, globals, null));
ccmeta.leg: oop idKeys = map_keys(keys);
ccmeta.leg:oop prim_keys(oop scope, oop params)
ccmeta.leg: if (is(Map, arg)) return map_keys(arg);
ccmeta.leg:oop prim_all_keys(oop scope, oop params)
ccmeta.leg: println(map_keys(yylval));
ccmeta.leg: map_set(globals, intern("keys" ), makeFunction(prim_keys, intern("keys" ), null, null, globals, null));
ccmeta.leg: map_set(globals, intern("_keys" ), makeFunction(prim_all_keys, intern("_keys" ), null, null, globals, null));
object.c:oop map_keys(oop map)

+ 98
- 52
src/ccmeta.leg Ver arquivo

@ -103,24 +103,16 @@ jb_record *jbs= NULL;
assert(jbs == &jbrec); \
jbs= jbrec.next
// this is the global scope
oop globals= 0;
oop program= 0;
oop prog_last= 0;
oop prog_objects= 0;
oop objects_elements= 0;
oop objects_last= 0;
oop prog_enums= 0;
oop prog_structs= 0;
oop prog_unions= 0;
oop enum_last= 0;
oop struct_last= 0;
oop union_last= 0;
// this is the global scope and other global variable for parsimony lang
oop globals = 0;
oop program = 0;
oop prog_last = 0;
oop prog_unions = 0;
oop prog_enums = 0;
oop prog_structs = 0;
oop union_last = 0;
oop enum_last = 0;
oop struct_last = 0;
#define DO_SYMBOLS() \
DO_PROTOS() _DO(__proto__) _DO(__name__) _DO(__default__) _DO(__arguments__) \
@ -1482,8 +1474,11 @@ start = m:metaCatch { yylval= m }
error = EOL* < (!EOL .)* EOL* (!EOL .)* > &{ error(yytext), 1 }
### A.1.3 Identifiers
# Identifiers rules
# 6.4.2.1
idOpt = id | {$$=newNullObject()}
id = <ID> { $$= new_C_id(yytext) } -
@ -1505,22 +1500,28 @@ IDREST = IDFIRST | [0-9]
digit = [0-9]
# universalCharacterName
### A.1.4 Universal character names
# universalCharacterName rule
# 6.4.3
universalCharacterName = "\\u" hexQuad
| "\\U" hexQuad hexQuad
hexQuad = hexadecimalDigit hexadecimalDigit hexadecimalDigit hexadecimalDigit
### A.1.5 Constants
# constant rule
# 6.4.4
constant = characterConstant
| floatingConstant
| integerConstant
| META_AT m:mvalue
# 6.4.4.1
# integerConstant rule
integerConstant = < ( hexadecimalConstant
@ -1549,6 +1550,7 @@ integerSuffix = ( [uU][lL]?[lL]? | [lL][lL]?[uU]? ) ( imaginarySuffix &{gn
imaginarySuffix = [ij]
# 6.4.4.2
# floatingConstant rule
floatingConstant = <( decimalFloatingConstant | hexadecimalFloatingConstant )> { $$= new_C_float(yytext); } -
@ -1577,6 +1579,7 @@ hexadecimalDigitSequence = hexadecimalDigit+
floatingSuffix = [fFlL] imaginarySuffix?
# 6.4.4.4
# characterConstant rule
characterConstant = < "'" cCharSequence "'" > { $$= new_C_char(yytext) } -
| < "L'" cCharSequence "'" > { $$= new_C_char(yytext) } -
@ -1597,8 +1600,11 @@ octalEscapeSequence = '\\' octalDigit octalDigit? octalDigit?
hexadecimalEscapeSequence = '\\x' hexadecimalDigit+
### A.1.6 String literals
# stringLiteral rule
# 6.4.5
stringLiteral = { listBegin(); }
( s:stringLiteralPart { listAppend(s) }
| META_AT META_AT META_LPAREN m:meta_exp META_RPAREN { listAppend(m) }
@ -1609,8 +1615,11 @@ stringLiteralPart = < '"' sCharSequence '"' > { $$= new_C_string(y
sCharSequence = ( escapeSequence | !EOL [^\"\\] )* #"
### A.2.1 Expressions
# primaryExpression rule
# 6.5.1
primaryExpression = META_AT ( META_LCB mstmts
#| < [a-zA-Z][a-zA-Z0-9]* > @{ printf("<%s>\n", yytext); exit(0) }
| mvalue
@ -1619,6 +1628,7 @@ primaryExpression = META_AT ( META_LCB mstmts
| l:LPAREN x:expression r:RPAREN { $$= new_C_subexpr(l, x, r) }
| l:LPAREN x:compoundStatement r:RPAREN &{gnu} { $$= new_C_subexpr(l, x, r) }
# 6.5.2
# postfixExpression rule
postfixExpression = o:LPAREN l:typeName p:RPAREN
@ -1638,6 +1648,7 @@ argumentExpressionList = { listBegin() }
)*
)? { $$= listEnd() }
# 6.5.3
# unaryExpression rule
unaryExpression = o:INC x:unaryExpression { $$= new_C_prefix(o, x) }
@ -1657,11 +1668,13 @@ unaryOperator = BAND | STAR | PLUS | MINUS | BNOT | LNOT
| REAL &{gnu}
| IMAG &{gnu}
# 6.5.4
# castExpression rule
castExpression = l:LPAREN t:typeName r:RPAREN x:castExpression { $$= new_C_cast(l, t, r, x) }
| unaryExpression
# 6.5.5
# multiplicativeExpression rule
multiplicativeExpression = l:castExpression
@ -1670,6 +1683,7 @@ multiplicativeExpression = l:castExpression
multiplicativeOperator = STAR | DIV | MOD
# 6.5.6
# additiveExpression rule
additiveExpression = l:multiplicativeExpression
@ -1678,6 +1692,7 @@ additiveExpression = l:multiplicativeExpression
additiveOperator = PLUS | MINUS
# 6.5.7
# shiftExpression rule
shiftExpression = l:additiveExpression
@ -1686,6 +1701,7 @@ shiftExpression = l:additiveExpression
shiftOperator = LSHIFT | RSHIFT
# 6.5.8
# relationalExpression rule
relationalExpression = l:shiftExpression
@ -1694,6 +1710,7 @@ relationalExpression = l:shiftExpression
relationalOperator = LT | LTE | GT | GTE
# 6.5.9
# equalityExpression rule
equalityExpression = l:relationalExpression
@ -1702,36 +1719,42 @@ equalityExpression = l:relationalExpression
equalityOperator = EQUAL | NOT_EQUAL
# 6.5.10
# andExpression rule
andExpression = l:equalityExpression
( o:BAND r:equalityExpression { l= new_C_binary(l, o, r) }
)* { $$= l }
# 6.5.11
# exclusiveOrExpression rule
exclusiveOrExpression = l:andExpression
( o:BXOR r:andExpression { l= new_C_binary(l, o, r) }
)* { $$= l }
# 6.5.12
# inclusiveOrExpression rule
inclusiveOrExpression = l:exclusiveOrExpression
( o:BOR r:exclusiveOrExpression { l= new_C_binary(l, o, r) }
)* { $$= l }
# 6.5.13
# logicalAndExpression rule
logicalAndExpression = l:inclusiveOrExpression
( o:LAND r:inclusiveOrExpression { l= new_C_binary(l, o, r) }
)* { $$= l }
# 6.5.14
# logicalOrExpression rule
logicalOrExpression = l:logicalAndExpression
( o:LOR r:logicalAndExpression { l= new_C_binary(l, o, r) }
)* { $$= l }
# 6.5.15
# conditionalExpression rule
conditionalExpression = l:logicalOrExpression
@ -1740,6 +1763,7 @@ conditionalExpression = l:logicalOrExpression
| { $$= l }
)
# 6.5.16
# assignmentExpressionOpt rule
assignmentExpressionOpt = assignmentExpression | {$$=newNullObject()}
@ -1751,6 +1775,7 @@ assignmentOperator = ASSIGN
| STAR_ASSIGN | DIV_ASSIGN | MOD_ASSIGN | PLUS_ASSIGN | MINUS_ASSIGN
| LSHIFT_ASSIGN | RSHIFT_ASSIGN | BAND_ASSIGN | BXOR_ASSIGN | BOR_ASSIGN
# 6.5.17
# expression rule
expression = l:assignmentExpression
@ -1761,8 +1786,11 @@ expressionOpt = expression | { $$= newNullObject() }
constantExpression = conditionalExpression
### A.2.2 Declarations
# declaration rule
# 6.7
declaration = @{ C_declarationBegin() }
( s:declarationSpecifiers
d:initDeclaratorListOpt
@ -1793,6 +1821,7 @@ initDeclarator = d:declarator
( a:ASSIGN i:initializer &{ !typedeffing } { d= new_C_binary(d, a, i) }
)? { $$= d }
# 6.7.1
# storageClassSpecifier rule
storageClassSpecifier = TYPEDEF @{ declarationTypedef() }
@ -1804,6 +1833,7 @@ parameterStorageClassSpecifier = REGISTER
functionStorageClassSpecifier = EXTERN | STATIC
# 6.7.2
# typeSpecifier rule
typeSpecifier = VOID | CHAR | SHORT | INT | LONG | FLOAT | DOUBLE | SIGNED | UNSIGNED | BOOL | COMPLEX
@ -1811,6 +1841,7 @@ typeSpecifier = VOID | CHAR | SHORT | INT | LONG | FLOAT | DOUBLE | SIGNED | U
| structOrUnionSpecifier
| enumSpecifier
# 6.7.2.1
# structOrUnionSpecifier rule
structOrUnionSpecifier = s:structOrUnion
@ -1859,6 +1890,7 @@ structDeclarator = ( c:COLON e:constantExpression
( a:attributeSpecifiers { d= new_C_attribution(d, a) }
)? { $$= d }
# 6.7.2.2
# enumSpecifier rule
enumSpecifier = e:ENUM
@ -1879,16 +1911,19 @@ enumerator = i:id
)*
( a:ASSIGN e:constantExpression | {a=e=newNullObject()} ) { $$= new_C_enumerator(i, a, e) }
# 6.7.3
# typeQualifier rule
typeQualifier = CONST | RESTRICT | VOLATILE
| __RESTRICT
# 6.7.4
# functionSpecifier rule
functionSpecifier = INLINE
| __INLINE
# 6.7.5
# declarator rule
declarator = # An attribute specifier list may appear immediately before a declarator
@ -1959,6 +1994,7 @@ identifierList = i:id { listWith(i) }
( c:COMMA i:id { listAppend2(c, i) }
)* { $$= listEnd() }
# 6.7.6
# typeName rule
typeName = s:specifierQualifierList d:abstractDeclaratorOpt { $$= new_C_declaration(s, d, newNullObject()) }
@ -1982,6 +2018,7 @@ directAbstractDeclarator = @{int nonEmpty= 0}
) r:RBRACKET @{++nonEmpty} { d= new_C_array(d, l, s, q, t, e, r) }
)* &{nonEmpty} { $$= d }
# 6.7.7
# typedefName rule
typedefName = <ID> &{ isTypedefName(yytext) } { $$= new_C_id(yytext) } -
@ -1990,6 +2027,7 @@ typedefName = &{ isTypedefName(yytext) } { $$= new_C_id(yytext) } -
| x:typeName r:RPAREN { $$= new_C_typeOf(t, l, x, newNullObject(), r) }
) &{gnu}
# 6.7.8
# initializer rule
initializer = l:LCURLY i:initializerList ( c:COMMA | {c=newNullObject()} ) r:RCURLY { $$= new_C_initializer(l, i, c, r) }
@ -2014,8 +2052,11 @@ designatorList = { listB
| l:DOT x:id { listAppend(new_C_binary(newNullObject(), l, x)) }
)+ { $$= listEnd() }
### A.2.3 Statements
# statement rule
# 6.8
statement = expressionStatement
| labeledStatement
| compoundStatement
@ -2023,6 +2064,7 @@ statement = expressionStatement
| iterationStatement
| jumpStatement
# 6.8.1
# labeledStatement rule
labeledStatement = i:id c:COLON
@ -2034,6 +2076,7 @@ labeledStatement = i:id c:COLON
| c:CASE x:constantRange d:COLON s:statement &{gnu} { $$= new_C_case(c, x, d, s) }
| d:DEFAULT c:COLON s:statement { $$= new_C_default(d, c, s) }
# 6.8.2
# compoundStatement rule
compoundStatement = @{ C_scopeBegin() }
@ -2049,17 +2092,20 @@ compoundStatement = @{ C_scopeBegin() }
@{ C_scopeEnd() }
| &{ C_scopeAbort() }
# 6.8.3
# expressionStatement rule
expressionStatement = SEMI
| x:expression s:SEMI { $$= new_C_exprStatement(x, s) }
# 6.8.4
# selectionStatement rule
selectionStatement = i:IF l:LPAREN x:expression r:RPAREN s:statement
( e:ELSE t:statement | {e=t=newNullObject()} ) { $$= new_C_if(i, l, x, r, s, e, t) }
| s:SWITCH l:LPAREN x:expression r:RPAREN t:statement { $$= new_C_switch(s, l, x, r, t) }
# 6.8.5
# iterationStatement rule
iterationStatement = w:WHILE l:LPAREN x:expression r:RPAREN s:statement { $$= new_C_while(w, l, x, r, s) }
@ -2069,6 +2115,7 @@ iterationStatement = w:WHILE l:LPAREN x:expression r:RPAREN s:statement
| f:FOR l:LPAREN a:declaration b:expressionOpt u:SEMI
c:expressionOpt r:RPAREN s:statement { $$= new_C_for(f, l, a, newNullObject(), b, u, c, r, s) }
# 6.8.6
# jumpStatement rule
jumpStatement = g:GOTO i:id t:SEMI { $$= new_C_goto(g, newNullObject(), i, t) }
@ -2077,8 +2124,11 @@ jumpStatement = g:GOTO i:id t:SEMI { $$= new_C_goto(g,
| r:RETURN x:expressionOpt t:SEMI { $$= new_C_return(r, x, t) }
| g:GOTO s:STAR x:expression t:SEMI &{gnu} { $$= new_C_goto(g, s, x, t) }
### A.2.4 External definitions
# externalDeclaration rule
# 6.9
## translationUnit = externalDeclaration+
externalDeclaration = <Space+> { $$= newComment(yytext); }
@ -3603,15 +3653,6 @@ oop prim_keys(oop scope, oop params)
return null;
}
oop prim_all_keys(oop scope, oop params)
{
if (map_hasIntegerKey(params, 0)) {
oop arg= get(params, Map, elements)[0].value;
if (is(Map, arg)) return map_allKeys(arg);
}
return null;
}
oop prim_values(oop scope, oop params)
{
if (map_hasIntegerKey(params, 0)) {
@ -4843,7 +4884,7 @@ void printTree(oop element, language id) {
void init()
{
# if (USE_GC)
# if (USE_GC)
GC_INIT();
# endif
@ -4853,7 +4894,6 @@ void init()
map_set(globals, intern("exit" ), makeFunction(prim_exit, intern("exit" ), null, null, globals, null));
map_set(globals, intern("keys" ), makeFunction(prim_keys, intern("keys" ), null, null, globals, null));
map_set(globals, intern("_keys" ), makeFunction(prim_all_keys, intern("_keys" ), null, null, globals, null));
map_set(globals, intern("values" ), makeFunction(prim_values, intern("values" ), null, null, globals, null));
map_set(globals, intern("length" ), makeFunction(prim_length, intern("length" ), null, null, globals, null));
map_set(globals, intern("print" ), makeFunction(prim_print, intern("print" ), null, null, globals, null));
@ -4889,22 +4929,28 @@ void init()
DO_PROTOS()
#undef _DO
program = makeMap();
prog_enums = makeMap();
prog_structs = makeMap();
prog_unions = makeMap();
prog_last = makeMap();
enum_last = makeMap();
struct_last = makeMap();
union_last = makeMap();
map_set(prog_enums , intern("last" ), enum_last );
map_set(prog_structs , intern("last" ), struct_last );
map_set(prog_unions , intern("last" ), union_last );
map_set(program , intern("structs" ), prog_structs );
map_set(program , intern("unions" ), prog_unions );
map_set(program , intern("enums" ), prog_enums );
map_set(globals , intern("program" ), program );
// Initialisation of parsimony global variable
program = makeMap();
prog_enums = makeMap();
prog_structs = makeMap();
prog_unions = makeMap();
prog_last = makeMap();
enum_last = makeMap();
struct_last = makeMap();
union_last = makeMap();
map_set(globals , intern("program"), program );
map_set(program , intern("structs"), prog_structs);
map_set(prog_structs, intern("last" ), struct_last );
map_set(program , intern("unions" ), prog_unions );
map_set(prog_unions , intern("last" ), union_last );
map_set(program , intern("enums" ), prog_enums );
map_set(prog_enums , intern("last" ), enum_last );
fixScope(globals);
@ -4945,10 +4991,10 @@ int main(int argc, char **argv)
}
if (opt_g) {
if (nalloc < 1024) printf("[GC: %lli bytes allocated]\n", nalloc );
else if (nalloc < 1024*1024) printf("[GC: %lli kB allocated]\n", nalloc / 1024 );
else if (nalloc < 1024*1024*1024) printf("[GC: %.2f MB allocated]\n", (double)nalloc / ( 1024*1024));
else printf("[GC: %.2f GB allocated]\n", (double)nalloc / (1024*1024*1024));
if (nalloc < 1024) printf("[GC: %lli bytes allocated]\n", nalloc );
else if (nalloc < 1024*1024) printf("[GC: %lli kB allocated]\n", nalloc / 1024 );
else if (nalloc < 1024*1024*1024) printf("[GC: %.2f MB allocated]\n", (double)nalloc / ( 1024*1024));
else printf("[GC: %.2f GB allocated]\n", (double)nalloc / (1024*1024*1024));
}
@ -4961,4 +5007,4 @@ int main(int argc, char **argv)
// Local Variables:
// indent-tabs-mode: nil
// End:-
// End:

+ 2
- 0
src/object.c Ver arquivo

@ -428,6 +428,8 @@ int oopcmp(oop a, oop b)
}
case String:
return strcmp(get(a, String, value), get(b, String, value));
case Symbol:
return strcmp(get(a, Symbol, name), get(b, Symbol, name));
default: {
intptr_t l= (intptr_t)a, r= (intptr_t)b;
if (l < r) return -1;

+ 1
- 1
src/parsimonyLibrary/boot.mc Ver arquivo

@ -59,7 +59,7 @@
continue;
append(t, s[i]);
}
s = treeCopy(t);
s = t;
ret;
}

+ 13
- 13
src/parsimonyLibrary/dynamicObjectExtDecl.mc Ver arquivo

@ -159,7 +159,7 @@ typedef struct __oop *oop;
send(object, method)
{
treeCopy(rmSemi(`declaration send(@@(newText(object)), @@(newText(method)));));
rmSemi(`declaration send(@@(newText(object)), @@(newText(method))););
}
everyExternalDeclaration(s)
@ -170,7 +170,7 @@ typedef struct __oop *oop;
for (i=length(program.last.declarationL); i>0; i--) {
program.last.declarationL[i] = program.last.declarationL[i-1];
};
program.last.declarationL[0] = treeCopy(`declaration int class; );
program.last.declarationL[0] = `declaration int class; ;
program.objects.function = "none";
return s;
}
@ -184,14 +184,14 @@ typedef struct __oop *oop;
param = rmSemi(`declaration struct __oop *__self;);
if (length(s.declarators.paramTypeL) > 0) {
append(s.declarators.paramTypeL, newComma());
append(s.declarators.paramTypeL, treeCopy(param));
append(s.declarators.paramTypeL, param);
} else {
s.declarators.paramTypeL = {};
s.declarators.paramTypeL[0] = treeCopy(param);
s.declarators.paramTypeL[0] = param;
}
tmp = {};
tmp[0] = makeln(`declaration struct @@(newId(program.objects.currentClassName, " ")) *self = (struct @@(newId(program.objects.currentClassName, " ")) *) __self;, 1);
s.compoundS.expression = treeCopy(fusion(tmp, s.compoundS.expression));
s.compoundS.expression = fusion(tmp, s.compoundS.expression);
program.objects.function = "none";
return s;
}
@ -199,7 +199,7 @@ typedef struct __oop *oop;
if (program.objects.function == "constructor") {
rawDeclaration = makeln(`declaration class = findClass(@@(newText("\"" + program.objects.currentClassName + "\"")));, 1);
t = {};
append(t, treeCopy(makeln(`declaration struct @@(newId(program.objects.currentClassName, " ")) *self = calloc(1, sizeof *self);, 1)));
append(t, makeln(`declaration struct @@(newId(program.objects.currentClassName, " ")) *self = calloc(1, sizeof *self);, 1));
// take the structure of self->foo
lhs = treeCopy(s.compoundS.expression[0].expression.lhs);
lhs.rhs = newId("class", " ");
@ -217,15 +217,15 @@ typedef struct __oop *oop;
t = {};
for(i in program.objects.methods) {
methodName = string(program.objects.methods[i]);
append(t, treeCopy(makeln(`declaration int @@(newId("_selector_" + methodName)) = findSelector(@@(newId("\"" + methodName + "\"")));, 1)));
append(t, makeln(`declaration int @@(newId("_selector_" + methodName)) = findSelector(@@(newId("\"" + methodName + "\"")));, 1));
}
for (i in program.objects.class) {
className = string(i); // can't work other way
append(t, treeCopy(makeln(`declaration int @@(newId("_class_" + className)) = findClass(@@(newId("\"" + className + "\"")));, 1)));
className = string(i);
append(t, makeln(`declaration int @@(newId("_class_" + className)) = findClass(@@(newId("\"" + className + "\"")));, 1));
for (k in program.objects.class[i]) {
linkedMethod = string(program.objects.class[i][k]);
castMethod = "(method_t) " + className + "_" + linkedMethod;
append(t, treeCopy(makeln(`declaration addMethod(@@(newId("_class_" + className)), @@(newId("_selector_" + linkedMethod)), @@(newId(castMethod)));, 1)));
linkedMethod = string(program.objects.class[i][k]);
castMethod = "(method_t) " + className + "_" + linkedMethod;
append(t, makeln(`declaration addMethod(@@(newId("_class_" + className)), @@(newId("_selector_" + linkedMethod)), @@(newId(castMethod)));, 1));
}
}
s.compoundS.expression = fusion(t, s.compoundS.expression);
@ -235,4 +235,4 @@ typedef struct __oop *oop;
}
nil;
}
}

+ 12
- 12
src/parsimonyLibrary/dynamicObjectParsFrom.mc Ver arquivo

@ -145,7 +145,7 @@ typedef struct __oop *oop;
for (i=length(exp.specifiers[0].declarationL); i>0; i--) {
exp.specifiers[0].declarationL[i] = exp.specifiers[0].declarationL[i-1];
};
exp.specifiers[0].declarationL[0] = treeCopy(`declaration int class; );
exp.specifiers[0].declarationL[0] = `declaration int class; ;
exp;
}
@ -161,14 +161,14 @@ typedef struct __oop *oop;
param = rmSemi(`declaration struct __oop *__self;);
if (length(decl.declarators.paramTypeL) > 0) {
append(decl.declarators.paramTypeL, newComma());
append(decl.declarators.paramTypeL, treeCopy(param));
append(decl.declarators.paramTypeL, param);
} else {
decl.declarators.paramTypeL = {};
decl.declarators.paramTypeL[0] = treeCopy(param);
decl.declarators.paramTypeL[0] = param;
}
tmp = {};
tmp[0] = makeln(`declaration struct @@(newId(id, " ")) *self = (struct @@(newId(id, " ")) *) __self;, 1);
decl.compoundS.expression = treeCopy(fusion(tmp, decl.compoundS.expression));
decl.compoundS.expression = fusion(tmp, decl.compoundS.expression);
program.objects.function = "none";
decl;
}
@ -178,7 +178,7 @@ typedef struct __oop *oop;
decl = parseFrom("func");
rawDeclaration = makeln(`declaration class = findClass(@@(newText("\"" + id + "\"")));, 1);
t = {};
append(t, treeCopy(makeln(`declaration struct @@(newId(id, " ")) *self = calloc(1, sizeof *self);, 1)));
append(t, makeln(`declaration struct @@(newId(id, " ")) *self = calloc(1, sizeof *self);, 1));
// take the structure of self->foo
lhs = treeCopy(decl.compoundS.expression[0].expression.lhs);
lhs.rhs = newId("class", " ");
@ -197,13 +197,13 @@ typedef struct __oop *oop;
{
// object = string(parseFrom("id").identifier);
method = parseFrom("error");
// treeCopy(rmSemi(`declaration send(@@(newText(object)), @@(newText(method)));));
// rmSemi(`declaration send(@@(newText(object)), @@(newText(method))););
nil;
}
send(object, method)
{
treeCopy(rmSemi(`declaration send(@@(newText(object)), @@(newText(method)));));
rmSemi(`declaration send(@@(newText(object)), @@(newText(method))););
}
everyExternalDeclaration(s)
@ -213,15 +213,15 @@ typedef struct __oop *oop;
t = {};
for(i in program.objects.methods) {
methodName = string(program.objects.methods[i]);
append(t, treeCopy(makeln(`declaration int @@(newId("_selector_" + methodName)) = findSelector(@@(newId("\"" + methodName + "\"")));, 1)));
append(t, makeln(`declaration int @@(newId("_selector_" + methodName)) = findSelector(@@(newId("\"" + methodName + "\"")));, 1));
}
for (i in program.objects.class) {
className = string(i); // can't work other way
append(t, treeCopy(makeln(`declaration int @@(newId("_class_" + className)) = findClass(@@(newId("\"" + className + "\"")));, 1)));
className = string(i);
append(t, makeln(`declaration int @@(newId("_class_" + className)) = findClass(@@(newId("\"" + className + "\"")));, 1));
for (k in program.objects.class[i]) {
linkedMethod = string(program.objects.class[i][k]);
castMethod = "(method_t) " + className + "_" + linkedMethod;
append(t, treeCopy(makeln(`declaration addMethod(@@(newId("_class_" + className)), @@(newId("_selector_" + linkedMethod)), @@(newId(castMethod)));, 1)));
append(t, makeln(`declaration addMethod(@@(newId("_class_" + className)), @@(newId("_selector_" + linkedMethod)), @@(newId(castMethod)));, 1));
}
}
s.compoundS.expression = fusion(t, s.compoundS.expression);
@ -231,4 +231,4 @@ typedef struct __oop *oop;
}
nil;
}
}

+ 4
- 0
src/tests/tests-c/00104.c Ver arquivo

@ -1,5 +1,9 @@
#include <stdint.h>
typedef int int32_t;
typedef long int64_t;
int
main()
{

+ 2
- 0
src/tests/tests-c/00187.c Ver arquivo

@ -1,5 +1,7 @@
#include <stdio.h>
typedef struct FILE FILE;
int main()
{
FILE *f = fopen("fred.txt", "w");

+ 3
- 0
src/tests/tests-c/00189.c Ver arquivo

@ -1,5 +1,8 @@
#include <stdio.h>
typedef struct FILE FILE;
FILE *stdout;
int fred(int p)
{
printf("yo %d\n", p);

+ 2
- 0
src/tests/tests-c/00220.c Ver arquivo

@ -2,6 +2,8 @@
#include <stdio.h>
#include <wchar.h>
typedef int wchar_t;
int main()
{
wchar_t s[] = L"hello$$你好¢¢世界€€world";

src/tests/tests-c/00062.c.err → src/tests/tests-cpp/00062.c Ver arquivo


src/tests/tests-c/00063.c.err → src/tests/tests-cpp/00063.c Ver arquivo


src/tests/tests-c/00066.c.err → src/tests/tests-cpp/00066.c Ver arquivo


src/tests/tests-c/00067.c.err → src/tests/tests-cpp/00067.c Ver arquivo


src/tests/tests-c/00068.c.err → src/tests/tests-cpp/00068.c Ver arquivo


src/tests/tests-c/00069.c.err → src/tests/tests-cpp/00069.c Ver arquivo


src/tests/tests-c/00070.c.err → src/tests/tests-cpp/00070.c Ver arquivo


src/tests/tests-c/00071.c.err → src/tests/tests-cpp/00071.c Ver arquivo


src/tests/tests-c/00074.c.err → src/tests/tests-cpp/00074.c Ver arquivo


src/tests/tests-c/00115.c → src/tests/tests-cpp/00115.c Ver arquivo


src/tests/tests-c/00122.c → src/tests/tests-cpp/00122.c Ver arquivo


src/tests/tests-c/00137.c → src/tests/tests-cpp/00137.c Ver arquivo


src/tests/tests-c/00162.c → src/tests/tests-cpp/00162.c Ver arquivo


src/tests/tests-c/00200.c → src/tests/tests-cpp/00200.c Ver arquivo


src/tests/tests-c/00202.c → src/tests/tests-cpp/00202.c Ver arquivo


src/tests/tests-c/00210.c → src/tests/tests-cpp/00210.c Ver arquivo


src/tests/tests-c/00219.c → src/tests/tests-cpp/00219.c Ver arquivo


src/tests/tests-c/00204.c → src/tests/tests-err/00204.c Ver arquivo


+ 2
- 12
src/tests/tests-parsimony/008.c Ver arquivo

@ -1,16 +1,6 @@
@{
newText(x) { { value: x, __proto__: C_string }; }
f(n) {
program.tmp = n;
`declaration int @@(newText(treeCopy(program.tmp)));;
}
`declaration int @@(n);;
}
f("x");
}
@{
program.tmp = "y";
nil;
}

+ 8
- 1
src/tests/tests-parsimony/009 Ver arquivo

@ -1 +1,8 @@
int x;
x = 1, y = 2, z = 3
x = 1, y = 2, z = 3
x = 1, y = 3, z = null
x = 1, y = null, z = 3
x = 3, y = null, z = 1
x = 3, y = 1, z = null
x = null, y = 1, z = 3
x = null, y = 3, z = 1

+ 12
- 7
src/tests/tests-parsimony/009.c Ver arquivo

@ -1,10 +1,15 @@
@{
newText(x) { { value: x, __proto__: C_string }; }
f(n) {
`declaration int @@(newText(treeCopy(n)));;
}
f(x, y, z) {
print("x = ", x, ", y = ", y, ", z = ", z, "\n");
nil;
}
f("x");
f(1, 2, 3);
f(x:1, y:2, z:3);
f(x:1, y:3);
f(x:1, z:3);
f(z:1,x:3);
f(y:1,x:3);
f(y:1,z:3);
f(z:1,y:3);
}

+ 0
- 8
src/tests/tests-parsimony/010 Ver arquivo

@ -1,8 +0,0 @@
x = 1, y = 2, z = 3
x = 1, y = 2, z = 3
x = 1, y = 3, z = null
x = 1, y = null, z = 3
x = 3, y = null, z = 1
x = 3, y = 1, z = null
x = null, y = 1, z = 3
x = null, y = 3, z = 1

+ 0
- 15
src/tests/tests-parsimony/010.c Ver arquivo

@ -1,15 +0,0 @@
@{
f(x, y, z) {
print("x = ", x, ", y = ", y, ", z = ", z, "\n");
nil;
}
f(1, 2, 3);
f(x:1, y:2, z:3);
f(x:1, y:3);
f(x:1, z:3);
f(z:1,x:3);
f(y:1,x:3);
f(y:1,z:3);
f(z:1,y:3);
}

+ 2
- 2
src/tests/tests-parsimony/realObjectED Ver arquivo

@ -134,11 +134,11 @@ double Point_getX(struct __oop *__self)
int main()
{
int _selector_magnitude= findSelector("magnitude");
int _selector_getX= findSelector("getX");
int _selector_magnitude= findSelector("magnitude");
int _class_Point= findClass("Point");
addMethod(_class_Point, _selector_magnitude, (method_t) Point_magnitude);
addMethod(_class_Point, _selector_getX, (method_t) Point_getX);
addMethod(_class_Point, _selector_magnitude, (method_t) Point_magnitude);
oop p = newPoint(3, 4);
send(p, magnitude);

+ 2
- 2
src/tests/tests-parsimony/realObjectPF Ver arquivo

@ -134,11 +134,11 @@ double Point_getX(struct __oop *__self)
int main()
{
int _selector_magnitude= findSelector("magnitude");
int _selector_getX= findSelector("getX");
int _selector_magnitude= findSelector("magnitude");
int _class_Point= findClass("Point");
addMethod(_class_Point, _selector_magnitude, (method_t) Point_magnitude);
addMethod(_class_Point, _selector_getX, (method_t) Point_getX);
addMethod(_class_Point, _selector_magnitude, (method_t) Point_magnitude);
oop p = newPoint(3, 4);
// @send p magnitude();

Carregando…
Cancelar
Salvar