diff --git a/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-exp.c b/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addrexp.tag.c similarity index 97% rename from nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-exp.c rename to nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addrexp.tag.c index f85417e..90bafd6 100644 --- a/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-exp.c +++ b/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addrexp.tag.c @@ -67,7 +67,7 @@ /* First part of user prologue. */ -#line 1 "src/monitor/sdb/addr-exp.y" +#line 1 "src/monitor/sdb/addrexp.y" #include #include @@ -76,7 +76,7 @@ fprintf(stderr, "Error: %s\n", s); } -#line 80 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-exp.c" +#line 80 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addrexp.tag.c" # ifndef YY_CAST # ifdef __cplusplus @@ -99,7 +99,7 @@ # endif # endif -#include "addr-exp.h" +#include "addrexp.h" /* Symbol kind. */ enum yysymbol_kind_t { @@ -1074,73 +1074,73 @@ yyreduce: switch (yyn) { case 2: /* input: expression */ -#line 15 "src/monitor/sdb/addr-exp.y" +#line 15 "src/monitor/sdb/addrexp.y" { printf("Final Result: %d\n", yyvsp[0]); } -#line 1080 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-exp.c" +#line 1080 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addrexp.tag.c" break; case 3: /* expression: term */ -#line 19 "src/monitor/sdb/addr-exp.y" +#line 19 "src/monitor/sdb/addrexp.y" { yyval = yyvsp[0]; } -#line 1086 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-exp.c" +#line 1086 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addrexp.tag.c" break; case 4: /* expression: expression '+' term */ -#line 20 "src/monitor/sdb/addr-exp.y" +#line 20 "src/monitor/sdb/addrexp.y" { yyval = yyvsp[-2] + yyvsp[0]; } -#line 1092 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-exp.c" +#line 1092 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addrexp.tag.c" break; case 5: /* expression: expression '-' term */ -#line 21 "src/monitor/sdb/addr-exp.y" +#line 21 "src/monitor/sdb/addrexp.y" { yyval = yyvsp[-2] - yyvsp[0]; } -#line 1098 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-exp.c" +#line 1098 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addrexp.tag.c" break; case 6: /* term: factor */ -#line 25 "src/monitor/sdb/addr-exp.y" +#line 25 "src/monitor/sdb/addrexp.y" { yyval = yyvsp[0]; } -#line 1104 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-exp.c" +#line 1104 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addrexp.tag.c" break; case 7: /* term: term '*' factor */ -#line 26 "src/monitor/sdb/addr-exp.y" +#line 26 "src/monitor/sdb/addrexp.y" { yyval = yyvsp[-2] * yyvsp[0]; } -#line 1110 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-exp.c" +#line 1110 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addrexp.tag.c" break; case 8: /* term: term '/' factor */ -#line 27 "src/monitor/sdb/addr-exp.y" +#line 27 "src/monitor/sdb/addrexp.y" { yyval = yyvsp[-2] / yyvsp[0]; } -#line 1116 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-exp.c" +#line 1116 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addrexp.tag.c" break; case 9: /* factor: NUMBER */ -#line 31 "src/monitor/sdb/addr-exp.y" +#line 31 "src/monitor/sdb/addrexp.y" { yyval = yyvsp[0]; } -#line 1122 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-exp.c" +#line 1122 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addrexp.tag.c" break; case 10: /* factor: HEX_NUMBER */ -#line 32 "src/monitor/sdb/addr-exp.y" +#line 32 "src/monitor/sdb/addrexp.y" { yyval = yyvsp[0]; } -#line 1128 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-exp.c" +#line 1128 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addrexp.tag.c" break; case 11: /* factor: '-' factor */ -#line 33 "src/monitor/sdb/addr-exp.y" +#line 33 "src/monitor/sdb/addrexp.y" { yyval = -yyvsp[0]; } -#line 1134 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-exp.c" +#line 1134 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addrexp.tag.c" break; case 12: /* factor: '(' expression ')' */ -#line 34 "src/monitor/sdb/addr-exp.y" +#line 34 "src/monitor/sdb/addrexp.y" { yyval = yyvsp[-1]; } -#line 1140 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-exp.c" +#line 1140 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addrexp.tag.c" break; -#line 1144 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-exp.c" +#line 1144 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addrexp.tag.c" default: break; } @@ -1333,5 +1333,5 @@ yyreturnlab: return yyresult; } -#line 37 "src/monitor/sdb/addr-exp.y" +#line 37 "src/monitor/sdb/addrexp.y" diff --git a/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-lex.c b/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addrexp.yy.c similarity index 98% rename from nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-lex.c rename to nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addrexp.yy.c index fe53fcd..5b05720 100644 --- a/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-lex.c +++ b/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addrexp.yy.c @@ -1,6 +1,6 @@ -#line 1 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-lex.c" +#line 1 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addrexp.yy.c" -#line 3 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-lex.c" +#line 3 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addrexp.yy.c" #define YY_NO_UNPUT 1 #define YY_NO_INPUT 1 @@ -449,11 +449,11 @@ int yy_flex_debug = 0; #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; -#line 1 "src/monitor/sdb/addr-lex.l" -#line 2 "src/monitor/sdb/addr-lex.l" - #include -#line 455 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-lex.c" -#line 456 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-lex.c" +#line 1 "src/monitor/sdb/addrexp.l" +#line 2 "src/monitor/sdb/addrexp.l" + #include +#line 455 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addrexp.yy.c" +#line 456 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addrexp.yy.c" #define INITIAL 0 @@ -670,10 +670,10 @@ YY_DECL } { -#line 6 "src/monitor/sdb/addr-lex.l" +#line 6 "src/monitor/sdb/addrexp.l" -#line 676 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-lex.c" +#line 676 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addrexp.yy.c" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -732,35 +732,35 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 8 "src/monitor/sdb/addr-lex.l" +#line 8 "src/monitor/sdb/addrexp.l" { yylval = strtol(yytext, NULL, 16); return HEX_NUMBER; } YY_BREAK case 2: YY_RULE_SETUP -#line 9 "src/monitor/sdb/addr-lex.l" +#line 9 "src/monitor/sdb/addrexp.l" { yylval = atoi(yytext); return NUMBER; } YY_BREAK case 3: YY_RULE_SETUP -#line 10 "src/monitor/sdb/addr-lex.l" +#line 10 "src/monitor/sdb/addrexp.l" { return *yytext; } YY_BREAK case 4: YY_RULE_SETUP -#line 11 "src/monitor/sdb/addr-lex.l" +#line 11 "src/monitor/sdb/addrexp.l" { } YY_BREAK case 5: YY_RULE_SETUP -#line 12 "src/monitor/sdb/addr-lex.l" +#line 12 "src/monitor/sdb/addrexp.l" { printf("Unexpected character: %s\n", yytext); } YY_BREAK case 6: YY_RULE_SETUP -#line 13 "src/monitor/sdb/addr-lex.l" +#line 13 "src/monitor/sdb/addrexp.l" ECHO; YY_BREAK -#line 763 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-lex.c" +#line 763 "/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addrexp.yy.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -1765,6 +1765,6 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 13 "src/monitor/sdb/addr-lex.l" +#line 13 "src/monitor/sdb/addrexp.l" diff --git a/nemu/scripts/build.mk b/nemu/scripts/build.mk index 7618f4e..0a04409 100644 --- a/nemu/scripts/build.mk +++ b/nemu/scripts/build.mk @@ -30,7 +30,6 @@ OBJS = $(SRCS:%.c=$(OBJ_DIR)/%.o) $(CXXSRC:%.cc=$(OBJ_DIR)/%.o) # Compilation patterns $(OBJ_DIR)/%.o: %.c @echo + CC $< - @echo $@ $< @mkdir -p $(dir $@) @$(CC) $(CFLAGS) -c -o $@ $< $(call call_fixdep, $(@:.o=.d), $@) @@ -41,6 +40,18 @@ $(OBJ_DIR)/%.o: %.cc @$(CXX) $(CFLAGS) $(CXXFLAGS) -c -o $@ $< $(call call_fixdep, $(@:.o=.d), $@) +$(OBJ_DIR)/%.tag.c: %.y + @echo + YACC $< + @echo $@ $< + @mkdir -p $(dir $@) + @$(YACC) $(YFLAGS) --header=$(<:.y=.h) -o $@ $< + +$(OBJ_DIR)/%.yy.c: %.l $(OBJ_DIR)/%.tag.c + @echo + LEX $< + @echo $@ $< + @mkdir -p $(dir $@) + @$(LEX) $(LFLAGS) -o $@ $< + # Depencies -include $(OBJS:.o=.d) diff --git a/nemu/src/monitor/sdb/addr-exp.h b/nemu/src/monitor/sdb/addrexp.h similarity index 94% rename from nemu/src/monitor/sdb/addr-exp.h rename to nemu/src/monitor/sdb/addrexp.h index f957d6a..b5310c4 100644 --- a/nemu/src/monitor/sdb/addr-exp.h +++ b/nemu/src/monitor/sdb/addrexp.h @@ -35,8 +35,8 @@ especially those whose name start with YY_ or yy_. They are private implementation details that can be changed or removed. */ -#ifndef YY_YY_SRC_MONITOR_SDB_ADDR_EXP_H_INCLUDED -# define YY_YY_SRC_MONITOR_SDB_ADDR_EXP_H_INCLUDED +#ifndef YY_YY_SRC_MONITOR_SDB_ADDREXP_H_INCLUDED +# define YY_YY_SRC_MONITOR_SDB_ADDREXP_H_INCLUDED /* Debug traces. */ #ifndef YYDEBUG # define YYDEBUG 0 @@ -81,4 +81,4 @@ extern YYSTYPE yylval; int yyparse (void); -#endif /* !YY_YY_SRC_MONITOR_SDB_ADDR_EXP_H_INCLUDED */ +#endif /* !YY_YY_SRC_MONITOR_SDB_ADDREXP_H_INCLUDED */ diff --git a/nemu/src/monitor/sdb/filelist.mk b/nemu/src/monitor/sdb/filelist.mk index b388333..bad7396 100644 --- a/nemu/src/monitor/sdb/filelist.mk +++ b/nemu/src/monitor/sdb/filelist.mk @@ -1,13 +1,13 @@ -SRCS-y += src/monitor/sdb/addr-exp.c src/monitor/sdb/addr-lex.c +SRCS-y += src/monitor/sdb/addrexp.tag.c src/monitor/sdb/addrexp.yy.c INC_PATH += src/monitor/sdb LFLAGS += -DYY_NO_UNPUT -DYY_NO_INPUT -/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-exp.c: src/monitor/sdb/addr-exp.y +$(BUILD_DIR)/src/monitor/sdb/addr-exp.c: src/monitor/sdb/addr-exp.y @echo + YACC $< @mkdir -p $(dir $@) @$(YACC) $(YFLAGS) --header=$(<:.y=.h) -o $@ $< -/home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-lex.c: src/monitor/sdb/addr-lex.l /home/xin/repo/ysyx-workbench/nemu/build/obj-riscv32-nemu-interpreter/src/monitor/sdb/addr-exp.c +$(BUILD_DIR)/src/monitor/sdb/addr-lex.c: src/monitor/sdb/addr-lex.l $(BUILD_DIR)/src/monitor/sdb/addr-exp.c @echo + LEX $< @mkdir -p $(dir $@) @$(LEX) $(LFLAGS) -o $@ $<