Skip to content

Commit

Permalink
Use more verbose syntax error messages
Browse files Browse the repository at this point in the history
Fixes #385
  • Loading branch information
Rangi42 authored and ISSOtm committed Jan 14, 2021
1 parent 57b734a commit eb4952c
Show file tree
Hide file tree
Showing 15 changed files with 239 additions and 137 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,15 @@ src/asm/parser.c: src/asm/parser.y
$QDEFS=; \
add_flag(){ \
if src/check_bison_ver.sh $$1 $$2; then \
DEFS="$$DEFS -D$$3"; \
DEFS="-D$$3 $$DEFS"; \
fi \
}; \
add_flag 3 5 api.token.raw=true; \
${BISON} -d $$DEFS ${YFLAGS} -o $@ $<
add_flag 3 6 parse.error=detailed; \
add_flag 3 0 parse.error=verbose; \
add_flag 3 0 parse.lac=full; \
echo "DEFS=$$DEFS"; \
${BISON} $$DEFS -d ${YFLAGS} -o $@ $<

.c.o:
$Q${CC} ${REALCFLAGS} ${PNGCFLAGS} -c -o $@ $<
Expand Down
8 changes: 8 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ set(BISON_FLAGS "")
if(BISON_VERSION VERSION_GREATER_EQUAL "3.5")
set(BISON_FLAGS "${BISON_FLAGS} -Dapi.token.raw=true")
endif()
if(BISON_VERSION VERSION_GREATER_EQUAL "3.6")
set(BISON_FLAGS "${BISON_FLAGS} -Dparse.error=detailed")
elseif(BISON_VERSION VERSION_GREATER_EQUAL "3.0")
set(BISON_FLAGS "${BISON_FLAGS} -Dparse.error=verbose")
endif()
if(BISON_VERSION VERSION_GREATER_EQUAL "3.0")
set(BISON_FLAGS "${BISON_FLAGS} -Dparse.lac=full")
endif()
BISON_TARGET(PARSER "asm/parser.y"
"${PROJECT_SOURCE_DIR}/src/asm/parser.c"
COMPILE_FLAGS "${BISON_FLAGS}"
Expand Down
10 changes: 6 additions & 4 deletions src/asm/lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ static struct KeywordMapping {
{"LD", T_Z80_LD},
{"LDI", T_Z80_LDI},
{"LDD", T_Z80_LDD},
{"LDIO", T_Z80_LDIO},
{"LDH", T_Z80_LDIO},
{"LDIO", T_Z80_LDH},
{"LDH", T_Z80_LDH},
{"NOP", T_Z80_NOP},
{"OR", T_Z80_OR},
{"POP", T_Z80_POP},
Expand Down Expand Up @@ -156,7 +156,7 @@ static struct KeywordMapping {
{"NZ", T_CC_NZ},
{"Z", T_CC_Z},
{"NC", T_CC_NC},
/* Handled in list of registers */
/* Handled after as T_TOKEN_C */
/* { "C", T_CC_C }, */

{"AF", T_MODE_AF},
Expand Down Expand Up @@ -276,11 +276,13 @@ static struct KeywordMapping {

{"RB", T_POP_RB},
{"RW", T_POP_RW},
/* Handled before as T_Z80_RL */
/* {"RL", T_POP_RL}, */
{"EQU", T_POP_EQU},
{"EQUS", T_POP_EQUS},
{"REDEF", T_POP_REDEF},

/* Handled before in list of CPU instructions */
/* Handled before as T_Z80_SET */
/* {"SET", T_POP_SET}, */

{"PUSHS", T_POP_PUSHS},
Expand Down
Loading

0 comments on commit eb4952c

Please sign in to comment.