Pārlūkot izejas kodu

ccmeta is ready to be tested

master
Nathan R pirms 3 gadiem
vecāks
revīzija
2a84230007
1 mainītis faili ar 40 papildinājumiem un 18 dzēšanām
  1. +40
    -18
      ccmeta.leg

+ 40
- 18
ccmeta.leg Parādīt failu

@ -30,6 +30,9 @@
_DO(GetVariable) _DO(GetMember) _DO(SetMember) _DO(GetIndex) _DO(SetIndex) \
_DO(Return) _DO(Break) _DO(Continue) _DO(Throw) _DO(Try) \
/* _DO(Quasiquote) _DO(Unquote) */ \
DO_C_PROTOS()
#define DO_C_PROTOS() \
_DO(Comment) _DO(Token) \
_DO(C_declaration) \
_DO(C_if) _DO(C_int) _DO(C_float) _DO(C_char) _DO(C_id) _DO(C_while) _DO(C_do) _DO(C_for) \
@ -49,12 +52,23 @@ DO_PROTOS()
#undef _DO
} proto_t;
#define SYMBOL_PAYLOAD proto_t prototype; int typeName;
#define SYMBOL_PAYLOAD proto_t prototype; int is_C_keyword;
#define DELTA 3
#include "scope.c"
#include "object.c"
#define DO_C_KEYWORDS() \
_DO(__alignof__) _DO(__alignof) _DO(asm) _DO(__asm) _DO(__asm__) _DO(__attribute__) _DO(auto) \
_DO(_Bool) _DO(break) _DO(case) _DO(char) _DO(_Complex) _DO(const) _DO(__const) _DO(continue) \
_DO(default) _DO(do) _DO(double) _DO(else) _DO(enum) _DO(extern) _DO(float) _DO(for) _DO(goto) \
_DO(if) _DO(inline) _DO(int) _DO(long) _DO(register) _DO(restrict) _DO(return) _DO(short) \
_DO(signed) _DO(sizeof) _DO(static) _DO(struct) _DO(switch) _DO(typedef) _DO(typeof) \
_DO(__typeof__) _DO(union) _DO(unsigned) _DO(void) _DO(volatile) _DO(while)
#define DO_C_KEYWORDS_GNU() \
_DO(__complex__) _DO(__inline__) _DO(__imag__) _DO(__label__) _DO(__real__)
#include <setjmp.h>
enum jb_t {
@ -815,8 +829,6 @@ oop new_C_parameter(oop paramSpecifiers, oop declarator) {
return object;
}
/* TODO */
OopStack listOfLists= BUFFER_INITIALISER;
oop currentList= 0;
@ -886,29 +898,25 @@ void C_scopeBegin() {
int C_scopeAbort() {
popScope();
assert(actualScope);
return 0;
}
void C_scopeEnd() {
popScope();
assert(actualScope);
}
int declarationId(char *s) {
oop object = intern(s);
int typeName = get(object, Symbol, typeName);
if (typeName) return 1;
if (!typdeffing) return 0;
set(object, Symbol, typeName, 1);
addId(s);
return 1;
}
int isTypedefName(char *s) {
oop object = intern(s);
if (!isTypedefed(s)) return 0;
return get(object, Symbol, typeName);
return 1;
}
oop new_C_conditional(oop logicalOrExpression, oop question, oop expression, oop colon, oop conditionalExpression) {
@ -1070,7 +1078,7 @@ int yyparsefrom(int (*yystart)(struct _yycontext *yy));
int irow= 0, icol= 0;
int gnu= 1;
int apl = 1; //TODO
int apl = 0; //TODO
char *errmsg= "no error";
@ -1117,7 +1125,7 @@ error = EOL* < (!EOL .)* EOL* (!EOL .)* > &{ error(yytext), 1
idOpt = id | {$$=newNullObject()}
id = <ID> { $$= new_C_id(yytext) } -
ID = <NAME> #| TODO : &{ !intern(yytext)->isKeyword }
ID = <NAME> &{ !get(intern(yytext), Symbol, is_C_keyword) }
name = <NAME> { $$= new_C_id(yytext) } -
NAME = IDFIRST IDREST*
@ -1225,7 +1233,7 @@ hexadecimalEscapeSequence = '\\x' hexadecimalDigit+
# 6.4.5
stringLiteral = { listBegin(); //TODO $$= listBegin() }
stringLiteral = { listBegin(); }
( s:stringLiteralPart { listAppend(s) }
)+ { $$= newString(listEnd()) }
@ -1728,7 +1736,7 @@ functionDeclarationSpecifiers
declarationListOpt = declarationList | {$$=newNullObject()}
declarationList = d:declaration { listWith(d); //TODO $$= listWith(d) }
declarationList = d:declaration { listWith(d); }
( d:declaration { listAppend(d) }
)* { $$= listEnd() }
@ -2836,6 +2844,10 @@ oop eval(oop scope, oop ast)
map_set(map, key, inc);
return val;
}
#define _DO(NAME) case t_##NAME:
DO_C_PROTOS();
break;
#undef _DO
}
printf("EVAL ");
println(ast);
@ -3775,15 +3787,25 @@ int main(int argc, char **argv)
/**/
// TODO
initScope();
#define _DO(NAME) set(intern(#NAME), Symbol, is_C_keyword, 1);
DO_C_KEYWORDS()
if(gnu) {
DO_C_KEYWORDS_GNU();
}
#undef _DO
/* File scope */
pushScope();
inputStackPush(NULL);
while (yyparse()) {
//outputNode(yylval);
printTree();
outputNode(yylval);
//printTree();
}
popScope();
assert(!actualScope);
return 0;
/**/

Notiek ielāde…
Atcelt
Saglabāt