ref: 5e2bd352395584264d22660da2070cf1c527bdcf
parent: 6655e04ef01bd78acd01f5d9efca4d50340b0a0f
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Tue Mar 2 15:46:17 EST 2021
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
--- a/src/asm/parser.y
+++ b/src/asm/parser.y
@@ -606,16 +606,22 @@
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();