X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fcc65%2Fcompile.c;h=de1144bb0f5c7c6e2c2e9bc02e64269ec926d6d0;hb=465d208b2b4ba80f41c6b7cfa673951a0218f61a;hp=8a57fa040cad88ef813de57105478646043a23c8;hpb=8eadb8aee02b36b1468f83351599cc970c1f1e3f;p=cc65 diff --git a/src/cc65/compile.c b/src/cc65/compile.c index 8a57fa040..de1144bb0 100644 --- a/src/cc65/compile.c +++ b/src/cc65/compile.c @@ -40,6 +40,7 @@ /* cc65 */ #include "asmlabel.h" +#include "asmstmt.h" #include "codegen.h" #include "declare.h" #include "error.h" @@ -47,6 +48,7 @@ #include "function.h" #include "global.h" #include "incpath.h" +#include "input.h" #include "litpool.h" #include "macrotab.h" #include "pragma.h" @@ -56,7 +58,7 @@ /*****************************************************************************/ -/* Code */ +/* Code */ /*****************************************************************************/ @@ -67,29 +69,32 @@ static void Parse (void) int comma; SymEntry* Entry; - NextToken (); /* "prime" the pump */ + /* Go... */ NextToken (); - while (curtok != TOK_CEOF) { + NextToken (); + + /* Parse until end of input */ + while (CurTok.Tok != TOK_CEOF) { DeclSpec Spec; Declaration Decl; int NeedStorage; /* Check for empty statements */ - if (curtok == TOK_SEMI) { + if (CurTok.Tok == TOK_SEMI) { NextToken (); continue; } /* Check for an ASM statement (which is allowed also on global level) */ - if (curtok == TOK_ASM) { - doasm (); + if (CurTok.Tok == TOK_ASM) { + AsmStatement (); ConsumeSemi (); continue; } /* Check for a #pragma */ - if (curtok == TOK_PRAGMA) { + if (CurTok.Tok == TOK_PRAGMA) { DoPragma (); continue; } @@ -104,7 +109,7 @@ static void Parse (void) } /* Check if this is only a type declaration */ - if (curtok == TOK_SEMI) { + if (CurTok.Tok == TOK_SEMI) { CheckEmptyDecl (&Spec); NextToken (); continue; @@ -155,7 +160,7 @@ static void Parse (void) unsigned Size = SizeOf (Decl.Type); /* Allow initialization */ - if (curtok == TOK_ASSIGN) { + if (CurTok.Tok == TOK_ASSIGN) { /* We cannot initialize types of unknown size, or * void types in non ANSI mode. @@ -210,7 +215,7 @@ static void Parse (void) } /* Check for end of declaration list */ - if (curtok == TOK_COMMA) { + if (CurTok.Tok == TOK_COMMA) { NextToken (); comma = 1; } else { @@ -224,7 +229,7 @@ static void Parse (void) /* Function */ if (!comma) { - if (curtok == TOK_SEMI) { + if (CurTok.Tok == TOK_SEMI) { /* Prototype only */ NextToken (); @@ -247,7 +252,7 @@ static void Parse (void) -void Compile (void) +void Compile (const char* FileName) /* Top level compile routine. Will setup things and call the parser. */ { char* Path; @@ -267,24 +272,24 @@ void Compile (void) } /* Add macros that are always defined */ - AddNumericMacro ("__CC65__", (VER_MAJOR * 0x100) + (VER_MINOR * 0x10) + VER_PATCH); + DefineNumericMacro ("__CC65__", (VER_MAJOR * 0x100) + (VER_MINOR * 0x10) + VER_PATCH); /* Strict ANSI macro */ if (ANSI) { - AddNumericMacro ("__STRICT_ANSI__", 1); + DefineNumericMacro ("__STRICT_ANSI__", 1); } /* Optimization macros */ if (Optimize) { - AddNumericMacro ("__OPT__", 1); + DefineNumericMacro ("__OPT__", 1); if (FavourSize == 0) { - AddNumericMacro ("__OPT_i__", 1); + DefineNumericMacro ("__OPT_i__", 1); } if (EnableRegVars) { - AddNumericMacro ("__OPT_r__", 1); + DefineNumericMacro ("__OPT_r__", 1); } if (InlineStdFuncs) { - AddNumericMacro ("__OPT_s__", 1); + DefineNumericMacro ("__OPT_s__", 1); } } @@ -297,6 +302,9 @@ void Compile (void) /* Generate the code generator preamble */ g_preamble (); + /* Open the input file */ + OpenMainFile (FileName); + /* Ok, start the ball rolling... */ Parse ();