1988-10-26 15:21:11 +00:00
|
|
|
/* U S E R O P T I O N - H A N D L I N G */
|
|
|
|
|
|
|
|
#include <em_arith.h>
|
|
|
|
#include <em_label.h>
|
|
|
|
|
2013-05-14 19:47:04 +00:00
|
|
|
#include "parameters.h"
|
1988-10-26 15:21:11 +00:00
|
|
|
#include "class.h"
|
|
|
|
#include "const.h"
|
|
|
|
#include "main.h"
|
2019-02-23 17:15:23 +00:00
|
|
|
#include "LLlex.h"
|
|
|
|
#include "node.h"
|
1988-10-26 15:21:11 +00:00
|
|
|
#include "type.h"
|
2019-02-23 17:15:23 +00:00
|
|
|
#include "options.h"
|
|
|
|
#include "error.h"
|
2019-02-23 16:44:50 +00:00
|
|
|
|
1988-10-26 15:21:11 +00:00
|
|
|
|
|
|
|
#define MINIDFSIZE 9
|
|
|
|
|
|
|
|
#if MINIDFSIZE < 9
|
|
|
|
You fouled up! MINIDFSIZE has to be at least 10 or the compiler will not
|
|
|
|
recognize some keywords!
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern int idfsize;
|
|
|
|
|
2019-02-23 16:44:50 +00:00
|
|
|
|
|
|
|
static int txt2int(register char **tp)
|
|
|
|
{
|
|
|
|
/* the integer pointed to by *tp is read, while increasing
|
|
|
|
*tp; the resulting value is yielded.
|
|
|
|
*/
|
|
|
|
register int val = 0;
|
|
|
|
register int ch;
|
|
|
|
|
|
|
|
while( ch = **tp, ch >= '0' && ch <= '9' ) {
|
|
|
|
val = val * 10 + ch - '0';
|
|
|
|
(*tp)++;
|
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DoOption(register char *text)
|
1988-10-26 15:21:11 +00:00
|
|
|
{
|
|
|
|
switch( *text++ ) {
|
|
|
|
|
|
|
|
default:
|
2019-02-23 16:44:50 +00:00
|
|
|
options[(int)text[-1]]++; /* flags, debug options etc. */
|
1988-10-26 15:21:11 +00:00
|
|
|
break;
|
|
|
|
/* recognized flags:
|
|
|
|
-i: largest value of set of integer
|
1989-05-03 10:30:22 +00:00
|
|
|
-u, -U: allow underscore in identifier
|
1988-10-26 15:21:11 +00:00
|
|
|
-w: no warnings
|
1989-05-03 10:30:22 +00:00
|
|
|
-R: no range checks
|
|
|
|
-A: range checks for array references
|
1988-10-26 15:21:11 +00:00
|
|
|
and many more if DEBUG
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
1991-02-18 17:15:11 +00:00
|
|
|
#ifdef DBSYMTAB
|
|
|
|
case 'g':
|
|
|
|
options['g'] = 1;
|
|
|
|
options['n'] = 1;
|
|
|
|
break;
|
|
|
|
#endif
|
1988-10-26 15:21:11 +00:00
|
|
|
case 'i': { /* largest value of set of integer */
|
|
|
|
char *t = text;
|
|
|
|
|
|
|
|
max_intset = txt2int(&t);
|
|
|
|
text = t;
|
|
|
|
if( max_intset <= (arith) 0 || *t ) {
|
|
|
|
error("bad -i flag : use -i<num>");
|
|
|
|
max_intset = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 'M': { /* maximum identifier length */
|
|
|
|
char *t = text;
|
|
|
|
|
|
|
|
idfsize = txt2int(&t);
|
|
|
|
text = t;
|
1989-05-03 10:30:22 +00:00
|
|
|
if( idfsize <= 0 || *t ) {
|
1988-10-26 15:21:11 +00:00
|
|
|
fatal("malformed -M option");
|
|
|
|
/*NOTREACHED*/
|
1989-05-03 10:30:22 +00:00
|
|
|
}
|
1988-10-26 15:21:11 +00:00
|
|
|
if( idfsize > IDFSIZE ) {
|
|
|
|
idfsize = IDFSIZE;
|
|
|
|
warning("maximum identifier length is %d", IDFSIZE);
|
|
|
|
}
|
|
|
|
if( idfsize < MINIDFSIZE ) {
|
|
|
|
idfsize = MINIDFSIZE;
|
|
|
|
warning("minimum identifier length is %d", MINIDFSIZE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-02-23 16:44:50 +00:00
|
|
|
/* case 'u': *//* underscore allowed in identifiers */
|
|
|
|
/* class('_') = STIDF;*/
|
|
|
|
/* inidf['_'] = 1;*/
|
|
|
|
/* break;*/
|
|
|
|
|
1988-10-26 15:21:11 +00:00
|
|
|
|
|
|
|
case 'V' : { /* set object sizes and alignment requirements */
|
1989-05-03 10:30:22 +00:00
|
|
|
/* syntax : -V[ [w|i|l|f|p] size? [.alignment]? ]* */
|
|
|
|
#ifndef NOCROSS
|
1988-10-26 15:21:11 +00:00
|
|
|
register arith size;
|
|
|
|
register int align;
|
|
|
|
char c, *t;
|
|
|
|
|
2019-02-23 16:44:50 +00:00
|
|
|
while( (c = *text++) !=0 ) {
|
2006-07-23 20:01:02 +00:00
|
|
|
char *strchr();
|
1988-10-26 15:21:11 +00:00
|
|
|
|
|
|
|
t = text;
|
|
|
|
size = txt2int(&t);
|
|
|
|
align = 0;
|
|
|
|
if( *(text = t) == '.' ) {
|
|
|
|
t = text + 1;
|
|
|
|
align = txt2int(&t);
|
|
|
|
text = t;
|
|
|
|
}
|
2006-07-23 20:01:02 +00:00
|
|
|
if( !strchr("wilfpS", c) )
|
1988-10-26 15:21:11 +00:00
|
|
|
error("-V: bad type indicator %c\n", c);
|
|
|
|
if( size )
|
|
|
|
switch( c ) {
|
|
|
|
case 'w': /* word */
|
|
|
|
word_size = size;
|
|
|
|
break;
|
|
|
|
case 'i': /* int */
|
|
|
|
int_size = size;
|
|
|
|
break;
|
1989-05-03 10:30:22 +00:00
|
|
|
case 'l': /* long */
|
|
|
|
long_size = size;
|
|
|
|
break;
|
1988-10-26 15:21:11 +00:00
|
|
|
case 'f': /* real */
|
|
|
|
real_size = size;
|
|
|
|
break;
|
|
|
|
case 'p': /* pointer */
|
|
|
|
pointer_size = size;
|
|
|
|
break;
|
|
|
|
case 'S': /* structure */
|
|
|
|
/* discard size */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( align )
|
|
|
|
switch( c ) {
|
|
|
|
case 'w': /* word */
|
|
|
|
word_align = align;
|
|
|
|
break;
|
|
|
|
case 'i': /* int */
|
|
|
|
int_align = align;
|
|
|
|
break;
|
1989-05-03 10:30:22 +00:00
|
|
|
case 'l': /* long */
|
|
|
|
long_align = align;
|
|
|
|
break;
|
1988-10-26 15:21:11 +00:00
|
|
|
case 'f': /* real */
|
|
|
|
real_align = align;
|
|
|
|
break;
|
|
|
|
case 'p': /* pointer */
|
|
|
|
pointer_align = align;
|
|
|
|
break;
|
|
|
|
case 'S': /* initial record alignment */
|
|
|
|
struct_align = align;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1991-12-17 15:05:43 +00:00
|
|
|
#endif /* NOCROSS */
|
1988-10-26 15:21:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-23 16:44:50 +00:00
|
|
|
|