Initialize translation tables

git-svn-id: svn://svn.cc65.org/cc65/trunk@327 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2000-09-14 19:26:13 +00:00
parent 2ff9f2fc1d
commit 1b4039be3b
10 changed files with 49 additions and 9 deletions

View File

@@ -42,6 +42,7 @@
/* common */ /* common */
#include "cmdline.h" #include "cmdline.h"
#include "target.h" #include "target.h"
#include "tgttrans.h"
#include "version.h" #include "version.h"
/* ca65 */ /* ca65 */
@@ -529,7 +530,7 @@ int main (int argc, char* argv [])
LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0])); LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0]));
break; break;
case 'g': case 'g':
OptDebugInfo (Arg, 0); OptDebugInfo (Arg, 0);
break; break;
@@ -574,7 +575,7 @@ int main (int argc, char* argv [])
break; break;
case 'V': case 'V':
OptVersion (Arg, 0); OptVersion (Arg, 0);
break; break;
case 'W': case 'W':
@@ -607,6 +608,9 @@ int main (int argc, char* argv [])
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
/* Intialize the target translation tables */
TgtTranslateInit ();
/* Initialize the scanner, open the input file */ /* Initialize the scanner, open the input file */
InitScanner (InFile); InitScanner (InFile);

View File

@@ -18,6 +18,7 @@
#include "anonname.h" #include "anonname.h"
#include "codegen.h" #include "codegen.h"
#include "datatype.h" #include "datatype.h"
#include "declattr.h"
#include "error.h" #include "error.h"
#include "expr.h" #include "expr.h"
#include "funcdesc.h" #include "funcdesc.h"
@@ -621,7 +622,7 @@ static void ParseAnsiParamList (FuncDesc* F)
DeclSpec Spec; DeclSpec Spec;
Declaration Decl; Declaration Decl;
DeclAttr Attr;
/* Allow an ellipsis as last parameter */ /* Allow an ellipsis as last parameter */
if (curtok == TOK_ELLIPSIS) { if (curtok == TOK_ELLIPSIS) {
@@ -658,6 +659,9 @@ static void ParseAnsiParamList (FuncDesc* F)
Spec.StorageClass &= ~SC_DEF; Spec.StorageClass &= ~SC_DEF;
} }
/* Parse an attribute */
ParseAttribute (&Decl, &Attr);
/* Create a symbol table entry */ /* Create a symbol table entry */
AddLocalSym (Decl.Ident, ParamTypeCvt (Decl.Type), Spec.StorageClass, 0); AddLocalSym (Decl.Ident, ParamTypeCvt (Decl.Type), Spec.StorageClass, 0);

View File

@@ -79,6 +79,7 @@ static char* ErrMsg [ERR_COUNT-1] = {
"`\"' expected", "`\"' expected",
"`:' expected", "`:' expected",
"`;' expected", "`;' expected",
"`,' expected",
"`(' expected", "`(' expected",
"`)' expected", "`)' expected",
"`[' expected", "`[' expected",
@@ -138,6 +139,7 @@ static char* ErrMsg [ERR_COUNT-1] = {
"Illegal modifier", "Illegal modifier",
"Illegal type qualifier", "Illegal type qualifier",
"Illegal storage class", "Illegal storage class",
"Illegal attribute",
"Illegal segment name: `%s'", "Illegal segment name: `%s'",
"Division by zero", "Division by zero",
"Modulo operation with zero", "Modulo operation with zero",

View File

@@ -37,7 +37,7 @@
#define ERROR_H #define ERROR_H
/* common */ /* common */
#include "attrib.h" #include "attrib.h"
@@ -79,6 +79,7 @@ enum Errors {
ERR_QUOTE_EXPECTED, ERR_QUOTE_EXPECTED,
ERR_COLON_EXPECTED, ERR_COLON_EXPECTED,
ERR_SEMICOLON_EXPECTED, ERR_SEMICOLON_EXPECTED,
ERR_COMMA_EXPECTED,
ERR_LPAREN_EXPECTED, ERR_LPAREN_EXPECTED,
ERR_RPAREN_EXPECTED, ERR_RPAREN_EXPECTED,
ERR_LBRACK_EXPECTED, ERR_LBRACK_EXPECTED,
@@ -138,6 +139,7 @@ enum Errors {
ERR_ILLEGAL_MODIFIER, ERR_ILLEGAL_MODIFIER,
ERR_ILLEGAL_QUALIFIER, ERR_ILLEGAL_QUALIFIER,
ERR_ILLEGAL_STORAGE_CLASS, ERR_ILLEGAL_STORAGE_CLASS,
ERR_ILLEGAL_ATTRIBUTE,
ERR_ILLEGAL_SEG_NAME, ERR_ILLEGAL_SEG_NAME,
ERR_DIV_BY_ZERO, ERR_DIV_BY_ZERO,
ERR_MOD_BY_ZERO, ERR_MOD_BY_ZERO,

View File

@@ -33,8 +33,10 @@
#include "../common/xmalloc.h" /* common */
#include "xmalloc.h"
/* cc65 */
#include "anonname.h" #include "anonname.h"
#include "asmlabel.h" #include "asmlabel.h"
#include "codegen.h" #include "codegen.h"

View File

@@ -44,6 +44,7 @@
#include "cmdline.h" #include "cmdline.h"
#include "fname.h" #include "fname.h"
#include "target.h" #include "target.h"
#include "tgttrans.h"
#include "version.h" #include "version.h"
#include "xmalloc.h" #include "xmalloc.h"
@@ -173,7 +174,10 @@ static void SetSys (const char* Sys)
default: default:
AbEnd ("Unknown target system type"); AbEnd ("Unknown target system type");
} }
/* Initialize the translation tables for the target system */
TgtTranslateInit ();
} }

View File

@@ -21,6 +21,7 @@ OBJS = anonname.o \
cpu.o \ cpu.o \
datatype.o \ datatype.o \
declare.o \ declare.o \
declattr.o \
error.o \ error.o \
expr.o \ expr.o \
exprheap.o \ exprheap.o \

View File

@@ -76,6 +76,7 @@ OBJS = anonname.obj \
cpu.obj \ cpu.obj \
datatype.obj \ datatype.obj \
declare.obj \ declare.obj \
declattr.obj \
error.obj \ error.obj \
expr.obj \ expr.obj \
exprheap.obj \ exprheap.obj \
@@ -134,6 +135,7 @@ FILE compile.obj
FILE cpu.obj FILE cpu.obj
FILE datatype.obj FILE datatype.obj
FILE declare.obj FILE declare.obj
FILE declattr.obj
FILE error.obj FILE error.obj
FILE expr.obj FILE expr.obj
FILE exprheap.obj FILE exprheap.obj

View File

@@ -11,7 +11,7 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <ctype.h> #include <ctype.h>
/* common */ /* common */
#include "tgttrans.h" #include "tgttrans.h"
@@ -331,7 +331,7 @@ static void CharConst (void)
nxtval = SignExtendChar (TgtTranslateChar (C)); nxtval = SignExtendChar (TgtTranslateChar (C));
/* Character constants have type int */ /* 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) void ConsumeLParen (void)
/* Check for a left parenthesis and skip it */ /* Check for a left parenthesis and skip it */
{ {

View File

@@ -198,6 +198,9 @@ void ConsumeColon (void);
void ConsumeSemi (void); void ConsumeSemi (void);
/* Check for a semicolon and skip it. */ /* Check for a semicolon and skip it. */
void ConsumeComma (void);
/* Check for a comma and skip it. */
void ConsumeLParen (void); void ConsumeLParen (void);
/* Check for a left parenthesis and skip it */ /* Check for a left parenthesis and skip it */