}
/* Something we know? */
- if (D->Tok != TOK_ID && D->Tok != TOK_NAME &&
- D->Tok != TOK_SIZE && D->Tok != TOK_MTIME) {
+ if (D->Tok != TOK_ID && D->Tok != TOK_MTIME &&
+ D->Tok != TOK_NAME && D->Tok != TOK_SIZE) {
/* Done */
break;
}
NextToken (D);
break;
+ case TOK_MTIME:
+ if (!IntConstFollows (D)) {
+ goto ErrorExit;
+ }
+ MTime = D->IVal;
+ NextToken (D);
+ InfoBits |= ibMTime;
+ break;
+
case TOK_NAME:
if (!StrConstFollows (D)) {
goto ErrorExit;
InfoBits |= ibSize;
break;
- case TOK_MTIME:
- if (!IntConstFollows (D)) {
- goto ErrorExit;
- }
- MTime = D->IVal;
- NextToken (D);
- InfoBits |= ibMTime;
- break;
-
default:
/* NOTREACHED */
UnexpectedToken (D);
}
/* Something we know? */
- if (D->Tok != TOK_FILE && D->Tok != TOK_SEGMENT &&
- D->Tok != TOK_LINE && D->Tok != TOK_RANGE) {
+ if (D->Tok != TOK_FILE && D->Tok != TOK_LINE &&
+ D->Tok != TOK_RANGE && D->Tok != TOK_SEGMENT) {
/* Done */
break;
}
NextToken (D);
break;
- case TOK_SEGMENT:
- if (!IntConstFollows (D)) {
- goto ErrorExit;
- }
- Segment = D->IVal;
- InfoBits |= ibSegment;
- NextToken (D);
- break;
-
case TOK_LINE:
if (!IntConstFollows (D)) {
goto ErrorExit;
InfoBits |= ibRange;
break;
+ case TOK_SEGMENT:
+ if (!IntConstFollows (D)) {
+ goto ErrorExit;
+ }
+ Segment = D->IVal;
+ InfoBits |= ibSegment;
+ NextToken (D);
+ break;
+
default:
/* NOTREACHED */
UnexpectedToken (D);
/* Check what the token was */
switch (Tok) {
+ case TOK_ADDRSIZE:
+ NextToken (D);
+ InfoBits |= ibAddrSize;
+ break;
+
case TOK_ID:
if (!IntConstFollows (D)) {
goto ErrorExit;
InfoBits |= ibOutputOffs;
break;
- case TOK_START:
- if (!IntConstFollows (D)) {
- goto ErrorExit;
- }
- Start = (cc65_addr) D->IVal;
- NextToken (D);
- InfoBits |= ibStart;
- break;
-
case TOK_SIZE:
if (!IntConstFollows (D)) {
goto ErrorExit;
InfoBits |= ibSize;
break;
- case TOK_ADDRSIZE:
+ case TOK_START:
+ if (!IntConstFollows (D)) {
+ goto ErrorExit;
+ }
+ Start = (cc65_addr) D->IVal;
NextToken (D);
- InfoBits |= ibAddrSize;
+ InfoBits |= ibStart;
break;
case TOK_TYPE:
static void ParseSym (InputData* D)
/* Parse a SYM line */
{
+ cc65_symbol_type Type;
+ long Value;
+ StrBuf SymName = STRBUF_INITIALIZER;
+ enum {
+ ibNone = 0x00,
+ ibSymName = 0x01,
+ ibValue = 0x02,
+ ibAddrSize = 0x04,
+ ibType = 0x08,
+ ibRequired = ibSymName | ibValue | ibAddrSize | ibType,
+ } InfoBits = ibNone;
+
/* Skip the SYM token */
NextToken (D);
- /* ### */
- SkipLine (D);
+ /* More stuff follows */
+ while (1) {
+
+ Token Tok;
+
+ /* Check for an unknown keyword */
+ if (D->Tok == TOK_IDENT) {
+ UnknownKeyword (D);
+ continue;
+ }
+
+ /* Something we know? */
+ if (D->Tok != TOK_ADDRSIZE && D->Tok != TOK_NAME &&
+ D->Tok != TOK_TYPE && D->Tok != TOK_VALUE) {
+ /* Done */
+ break;
+ }
+
+ /* Remember the token, skip it, check for equal */
+ Tok = D->Tok;
+ NextToken (D);
+ if (!ConsumeEqual (D)) {
+ goto ErrorExit;
+ }
+
+ /* Check what the token was */
+ switch (Tok) {
+
+ case TOK_ADDRSIZE:
+ NextToken (D);
+ InfoBits |= ibAddrSize;
+ break;
+
+ case TOK_NAME:
+ if (!StrConstFollows (D)) {
+ goto ErrorExit;
+ }
+ SB_Copy (&SymName, &D->SVal);
+ SB_Terminate (&SymName);
+ InfoBits |= ibSymName;
+ NextToken (D);
+ break;
+
+ case TOK_TYPE:
+ switch (D->Tok) {
+ case TOK_EQUATE:
+ Type = CC65_SYM_EQUATE;
+ break;
+ case TOK_LABEL:
+ Type = CC65_SYM_LABEL;
+ break;
+ default:
+ ParseError (D, CC65_ERROR,
+ "Unknown value for attribute \"type\"");
+ SkipLine (D);
+ goto ErrorExit;
+ }
+ NextToken (D);
+ InfoBits |= ibType;
+ break;
+
+ case TOK_VALUE:
+ if (!IntConstFollows (D)) {
+ goto ErrorExit;
+ }
+ Value = D->IVal;
+ InfoBits |= ibValue;
+ NextToken (D);
+ break;
+
+ default:
+ /* NOTREACHED */
+ UnexpectedToken (D);
+ goto ErrorExit;
+
+ }
+
+ /* Comma or done */
+ if (D->Tok != TOK_COMMA) {
+ break;
+ }
+ NextToken (D);
+ }
+
+ /* Check for end of line */
+ if (D->Tok != TOK_EOL && D->Tok != TOK_EOF) {
+ UnexpectedToken (D);
+ SkipLine (D);
+ goto ErrorExit;
+ }
+
+ /* Check for required and/or matched information */
+ if ((InfoBits & ibRequired) != ibRequired) {
+ ParseError (D, CC65_ERROR, "Required attributes missing");
+ goto ErrorExit;
+ }
+
+ /* Create the symbol info and remember it */
+#if 0
+ S = NewSegInfo (&SegName, Id, Start, Size, &OutputName, OutputOffs);
+ CollAppend (&D->Info->SegInfoByName, S);
+#endif
+
+ErrorExit:
+ /* Entry point in case of errors */
+ SB_Done (&SymName);
+ return;
}
*/
typedef struct cc65_linedata cc65_linedata;
struct cc65_linedata {
- const char* source_name; /* Name of the file */
- unsigned long source_size; /* Size of file */
- unsigned long source_mtime; /* Modification time */
- cc65_line source_line; /* Line number */
- cc65_addr line_start; /* Start address for this line */
- cc65_addr line_end; /* End address for this line */
- const char* output_name; /* Output file */
- unsigned long output_offs; /* Offset in output file */
+ const char* source_name; /* Name of the file */
+ unsigned long source_size; /* Size of file */
+ unsigned long source_mtime; /* Modification time */
+ cc65_line source_line; /* Line number */
+ cc65_addr line_start; /* Start address for this line */
+ cc65_addr line_end; /* End address for this line */
+ const char* output_name; /* Output file */
+ unsigned long output_offs; /* Offset in output file */
};
typedef struct cc65_lineinfo cc65_lineinfo;
/* Source file information */
typedef struct cc65_sourcedata cc65_sourcedata;
struct cc65_sourcedata {
- const char* source_name; /* Name of the file */
- unsigned long source_size; /* Size of file */
- unsigned long source_mtime; /* Modification time */
+ const char* source_name; /* Name of the file */
+ unsigned long source_size; /* Size of file */
+ unsigned long source_mtime; /* Modification time */
};
typedef struct cc65_sourceinfo cc65_sourceinfo;
*/
typedef struct cc65_segmentdata cc65_segmentdata;
struct cc65_segmentdata {
- const char* segment_name; /* Name of the segment */
- cc65_addr segment_start; /* Start address of segment */
- cc65_addr segment_size; /* Size of segment */
- const char* output_name; /* Output file this seg was written to */
- unsigned long output_offs; /* Offset of this seg in output file */
+ const char* segment_name; /* Name of the segment */
+ cc65_addr segment_start; /* Start address of segment */
+ cc65_addr segment_size; /* Size of segment */
+ const char* output_name; /* Output file this seg was written to */
+ unsigned long output_offs; /* Offset of this seg in output file */
};
typedef struct cc65_segmentinfo cc65_segmentinfo;
cc65_segmentdata data[1]; /* Data sets, number is dynamic */
};
+/* Symbol information */
+typedef enum {
+ CC65_SYM_EQUATE,
+ CC65_SYM_LABEL /* Some sort of address */
+} cc65_symbol_type;
+
+typedef struct cc65_symboldata cc65_symboldata;
+struct cc65_symboldata {
+ const char* symbol_name; /* Name of symbol */
+ cc65_symbol_type symbol_type; /* Type of symbol */
+ long symbol_value; /* Value of symbol */
+};
+
+typedef struct cc65_symbolinfo cc65_symbolinfo;
+struct cc65_symbolinfo {
+ unsigned count; /* Number of data sets that follow */
+ cc65_symboldata data[1]; /* Data sets, number is dynamic */
+};
+
/*****************************************************************************/