From: cuz Date: Thu, 14 Sep 2000 19:26:13 +0000 (+0000) Subject: Initialize translation tables X-Git-Tag: V2.12.0~3196 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1b4039be3be867c152ddc00290f18ef4ce6469db;p=cc65 Initialize translation tables git-svn-id: svn://svn.cc65.org/cc65/trunk@327 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/ca65/main.c b/src/ca65/main.c index ecbb58ec9..1601699e2 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -42,6 +42,7 @@ /* common */ #include "cmdline.h" #include "target.h" +#include "tgttrans.h" #include "version.h" /* ca65 */ @@ -529,7 +530,7 @@ int main (int argc, char* argv []) LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0])); break; - case 'g': + case 'g': OptDebugInfo (Arg, 0); break; @@ -574,7 +575,7 @@ int main (int argc, char* argv []) break; case 'V': - OptVersion (Arg, 0); + OptVersion (Arg, 0); break; case 'W': @@ -607,6 +608,9 @@ int main (int argc, char* argv []) exit (EXIT_FAILURE); } + /* Intialize the target translation tables */ + TgtTranslateInit (); + /* Initialize the scanner, open the input file */ InitScanner (InFile); diff --git a/src/cc65/declare.c b/src/cc65/declare.c index 3f285244b..e97cb4577 100644 --- a/src/cc65/declare.c +++ b/src/cc65/declare.c @@ -18,6 +18,7 @@ #include "anonname.h" #include "codegen.h" #include "datatype.h" +#include "declattr.h" #include "error.h" #include "expr.h" #include "funcdesc.h" @@ -621,7 +622,7 @@ static void ParseAnsiParamList (FuncDesc* F) DeclSpec Spec; Declaration Decl; - + DeclAttr Attr; /* Allow an ellipsis as last parameter */ if (curtok == TOK_ELLIPSIS) { @@ -658,6 +659,9 @@ static void ParseAnsiParamList (FuncDesc* F) Spec.StorageClass &= ~SC_DEF; } + /* Parse an attribute */ + ParseAttribute (&Decl, &Attr); + /* Create a symbol table entry */ AddLocalSym (Decl.Ident, ParamTypeCvt (Decl.Type), Spec.StorageClass, 0); diff --git a/src/cc65/error.c b/src/cc65/error.c index 9d0455ae9..221a4649c 100644 --- a/src/cc65/error.c +++ b/src/cc65/error.c @@ -79,6 +79,7 @@ static char* ErrMsg [ERR_COUNT-1] = { "`\"' expected", "`:' expected", "`;' expected", + "`,' expected", "`(' expected", "`)' expected", "`[' expected", @@ -138,6 +139,7 @@ static char* ErrMsg [ERR_COUNT-1] = { "Illegal modifier", "Illegal type qualifier", "Illegal storage class", + "Illegal attribute", "Illegal segment name: `%s'", "Division by zero", "Modulo operation with zero", diff --git a/src/cc65/error.h b/src/cc65/error.h index d8b52ae47..326ce37be 100644 --- a/src/cc65/error.h +++ b/src/cc65/error.h @@ -37,7 +37,7 @@ #define ERROR_H - + /* common */ #include "attrib.h" @@ -79,6 +79,7 @@ enum Errors { ERR_QUOTE_EXPECTED, ERR_COLON_EXPECTED, ERR_SEMICOLON_EXPECTED, + ERR_COMMA_EXPECTED, ERR_LPAREN_EXPECTED, ERR_RPAREN_EXPECTED, ERR_LBRACK_EXPECTED, @@ -138,6 +139,7 @@ enum Errors { ERR_ILLEGAL_MODIFIER, ERR_ILLEGAL_QUALIFIER, ERR_ILLEGAL_STORAGE_CLASS, + ERR_ILLEGAL_ATTRIBUTE, ERR_ILLEGAL_SEG_NAME, ERR_DIV_BY_ZERO, ERR_MOD_BY_ZERO, diff --git a/src/cc65/locals.c b/src/cc65/locals.c index 332c7589c..d17b8f811 100644 --- a/src/cc65/locals.c +++ b/src/cc65/locals.c @@ -33,8 +33,10 @@ -#include "../common/xmalloc.h" - +/* common */ +#include "xmalloc.h" + +/* cc65 */ #include "anonname.h" #include "asmlabel.h" #include "codegen.h" diff --git a/src/cc65/main.c b/src/cc65/main.c index 72459a412..0b2e0e709 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -44,6 +44,7 @@ #include "cmdline.h" #include "fname.h" #include "target.h" +#include "tgttrans.h" #include "version.h" #include "xmalloc.h" @@ -173,7 +174,10 @@ static void SetSys (const char* Sys) default: AbEnd ("Unknown target system type"); - } + } + + /* Initialize the translation tables for the target system */ + TgtTranslateInit (); } diff --git a/src/cc65/make/gcc.mak b/src/cc65/make/gcc.mak index 09c5eb3c3..5543986c4 100644 --- a/src/cc65/make/gcc.mak +++ b/src/cc65/make/gcc.mak @@ -21,6 +21,7 @@ OBJS = anonname.o \ cpu.o \ datatype.o \ declare.o \ + declattr.o \ error.o \ expr.o \ exprheap.o \ diff --git a/src/cc65/make/watcom.mak b/src/cc65/make/watcom.mak index 36393448a..ecd69783c 100644 --- a/src/cc65/make/watcom.mak +++ b/src/cc65/make/watcom.mak @@ -76,6 +76,7 @@ OBJS = anonname.obj \ cpu.obj \ datatype.obj \ declare.obj \ + declattr.obj \ error.obj \ expr.obj \ exprheap.obj \ @@ -134,6 +135,7 @@ FILE compile.obj FILE cpu.obj FILE datatype.obj FILE declare.obj +FILE declattr.obj FILE error.obj FILE expr.obj FILE exprheap.obj diff --git a/src/cc65/scanner.c b/src/cc65/scanner.c index 47446de4d..5249b7134 100644 --- a/src/cc65/scanner.c +++ b/src/cc65/scanner.c @@ -11,7 +11,7 @@ #include #include #include - + /* common */ #include "tgttrans.h" @@ -331,7 +331,7 @@ static void CharConst (void) nxtval = SignExtendChar (TgtTranslateChar (C)); /* Character constants have type int */ - nxttype = type_int; + nxttype = type_int; } @@ -806,6 +806,22 @@ void ConsumeSemi (void) +void ConsumeComma (void) +/* Check for a comma and skip it. */ +{ + /* Try do be smart about typos... */ + if (CurTok.Tok == TOK_COMMA) { + NextToken (); + } else { + Error (ERR_COMMA_EXPECTED); + if (CurTok.Tok == TOK_SEMI) { + NextToken (); + } + } +} + + + void ConsumeLParen (void) /* Check for a left parenthesis and skip it */ { diff --git a/src/cc65/scanner.h b/src/cc65/scanner.h index c3224a4bd..55c37de5c 100644 --- a/src/cc65/scanner.h +++ b/src/cc65/scanner.h @@ -198,6 +198,9 @@ void ConsumeColon (void); void ConsumeSemi (void); /* Check for a semicolon and skip it. */ +void ConsumeComma (void); +/* Check for a comma and skip it. */ + void ConsumeLParen (void); /* Check for a left parenthesis and skip it */