From 5e2bd352395584264d22660da2070cf1c527bdcf Mon Sep 17 00:00:00 2001 From: Rangi Date: Tue, 2 Mar 2021 20:46:17 -0500 Subject: [PATCH] Factor out a 'plain_directive' parser rule similar to the reverted 'last_line' Also expand on the comment explaining how the EOF-newline hack affects the parser --- src/asm/parser.y | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/asm/parser.y b/src/asm/parser.y index c09a9dbd..30a08c41 100644 --- a/src/asm/parser.y +++ b/src/asm/parser.y @@ -606,16 +606,22 @@ enum { asmfile : lines ; -/* Note: The lexer adds T_NEWLINE at the end of the input */ +/* + * The lexer adds T_NEWLINE at the end of the file if one was not + * already present, so we can rely on it to end a line. + */ lines : %empty | lines line ; -line : label T_NEWLINE - | label cpu_command T_NEWLINE - | label macro T_NEWLINE - | label directive T_NEWLINE - | assignment_directive T_NEWLINE +plain_directive : label + | label cpu_command + | label macro + | label directive + | assignment_directive +; + +line : plain_directive T_NEWLINE | line_directive /* Directives that manage newlines themselves */ | error T_NEWLINE { /* Continue parsing the next line on a syntax error */ fstk_StopRept();