From 6812f0e89f4c32d9bd94f9c70713766aa2cdbe6f Mon Sep 17 00:00:00 2001 From: Steve Chamberlain Date: Tue, 7 May 1991 19:16:33 +0000 Subject: [PATCH] Fixed the shift reduce errors in the grammer using the yacc debugger. Removed some lint highlighted by the same. --- ld/ldexp.c | 12 +++++------- ld/ldgram.y | 45 +++++++++++++++++++++++---------------------- ld/ldlex.l | 3 --- 3 files changed, 28 insertions(+), 32 deletions(-) diff --git a/ld/ldexp.c b/ld/ldexp.c index fe86a7c..c91af29 100644 --- a/ld/ldexp.c +++ b/ld/ldexp.c @@ -65,7 +65,6 @@ token_code_type code; } table[] = { INT, "int", - CHAR,"char", NAME,"NAME", PLUSEQ,"+=", MINUSEQ,"-=", @@ -86,17 +85,16 @@ token_code_type code; ALIGN_K,"ALIGN", BLOCK,"BLOCK", SECTIONS,"SECTIONS", - ALIGNMENT,"ALIGNMENT", SIZEOF_HEADERS,"SIZEOF_HEADERS", NEXT,"NEXT", SIZEOF,"SIZEOF", ADDR,"ADDR", MEMORY,"MEMORY", - DSECT,"DSECT", - NOLOAD,"NOLOAD", - COPY,"COPY", - INFO,"INFO", - OVERLAY,"OVERLAY", + + + + + DEFINED,"DEFINED", TARGET_K,"TARGET", SEARCH_DIR,"SEARCH_DIR", diff --git a/ld/ldgram.y b/ld/ldgram.y index 419c54e..dbdeaa4 100644 --- a/ld/ldgram.y +++ b/ld/ldgram.y @@ -88,10 +88,10 @@ boolean ldgram_had_equals = false; } -%type exp opt_exp exp_head +%type exp opt_exp %type fill_opt opt_block %type memspec_opt -%token INT CHAR +%token INT %token NAME %type length @@ -105,30 +105,32 @@ boolean ldgram_had_equals = false; %left EQ NE %left '<' '>' LE GE %left LSHIFT RSHIFT + %left '+' '-' %left '*' '/' '%' + +/*%token '+' '-' '*' '/' '%'*/ %right UNARY %left '(' %token ALIGN_K BLOCK LONG SHORT BYTE %token SECTIONS %token '{' '}' -%token ALIGNMENT SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH -%token NEXT SIZEOF ADDR SCRIPT ENDSCRIPT SIZEOF_HEADERS +%token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH +%token SIZEOF_HEADERS %token MEMORY -%token DSECT NOLOAD COPY INFO OVERLAY %token NAME DEFINED TARGET_K SEARCH_DIR MAP ENTRY %token OPTION_e OPTION_c OPTION_noinhibit_exec OPTION_s OPTION_S OPTION_sort_common %token OPTION_format OPTION_F OPTION_u - +%token SIZEOF NEXT ADDR %token OPTION_d OPTION_dc OPTION_dp OPTION_x OPTION_X OPTION_defsym %token OPTION_v OPTION_M OPTION_t STARTUP HLL SYSLIB FLOAT NOFLOAT -%token OPTION_n OPTION_r OPTION_o OPTION_b OPTION_A OPTION_R +%token OPTION_n OPTION_r OPTION_o OPTION_b OPTION_R %token OPTION_l OPTION_L OPTION_T OPTION_Aarch OPTION_Tfile OPTION_Texp %token OPTION_Ur %token ORIGIN FILL OPTION_g -%token LENGTH BIND SUBSECTION_ALIGN CREATE_OBJECT_SYMBOLS INPUT OUTPUT -%type assign_op SIZEOF NEXT ADDR -%type assignment +%token LENGTH CREATE_OBJECT_SYMBOLS INPUT OUTPUT +%type assign_op + %type filename %{ @@ -284,7 +286,7 @@ command_line_option: { } NAME '=' - exp_head + exp { lang_add_assignment(exp_assop($4,$3,$5)); } @@ -405,12 +407,12 @@ statement: lang_add_attribute(lang_object_symbols_statement_enum); } | statement input_section_spec - | statement length '(' exp_head ')' + | statement length '(' exp ')' { lang_add_data($2,$4); } - | statement FILL '(' exp_head ')' + | statement FILL '(' exp ')' { lang_add_fill (exp_get_value_int($4, @@ -431,7 +433,7 @@ length: ; fill_opt: - '=' exp_head + '=' exp { $$ = exp_get_value_int($2, 0, @@ -468,12 +470,11 @@ end: ';' | ',' assignment: - - NAME '=' exp_head + NAME '=' exp { lang_add_assignment(exp_assop($2,$1,$3)); } - | NAME assign_op exp_head + | NAME assign_op exp { lang_add_assignment(exp_assop('=',$1,exp_binop($2,exp_nameop(NAME,$1),$3))); } @@ -657,18 +658,18 @@ opt_things: } ; -exp_head: - exp { $$ = $1; } - ; + + + opt_exp: - exp_head + exp { $$ = $1; } | { $$= (etree_type *)NULL; } ; opt_block: - BLOCK '(' exp_head ')' + BLOCK '(' exp ')' { $$ = exp_get_value_int($3, 1L, "block", diff --git a/ld/ldlex.l b/ld/ldlex.l index b1b9619..7d50ccd 100644 --- a/ld/ldlex.l +++ b/ld/ldlex.l @@ -68,11 +68,8 @@ keyword_type keywords[] = "BLOCK",BLOCK, "LENGTH",LENGTH, "ALIGN",ALIGN_K, -"SUBSECTION_ALIGN",SUBSECTION_ALIGN, "ADDR",ADDR, "ENTRY",ENTRY, -"SCRIPT", SCRIPT, -"ENDSCRIPT", ENDSCRIPT, "NEXT",NEXT, "sizeof_headers",SIZEOF_HEADERS, "SIZEOF_HEADERS",SIZEOF_HEADERS, -- 2.7.4