Hi, On Tue, Dec 06, 2016 at 10:52:06PM -0500, Ricky wrote:
> Your syntax implies that [\n] should be treated as [;]. So why not use [\n] > as alternative? Unfortunately, it's not that easy. var foo = 4 + 5 is also allowed. This can lead to interesting hidden bugs[1], but is valid. Automatic Semicolon Insertion[2] is defined as a last-resort mechanism during parsing. I'm currently trying to inline rules, e.g. creating rules like variable_statement: "var" variable_declaration_list ";" | "var" variable_declaration_list after_variable_statement; after_variable_statement: variable_statement | throw_statement | ... listing the alternatives that imply a semicolon there, but this doesn't account for closing a block with a right brace. The irony is that the parser does almost the right thing -- it is stuck in the state member_expression: primary_expression . | member_expression . "." identifier | member_expression . "[" assignment_expression_in "]" | ... where it needs a lookahead token to decide between reducing to primary_expression and shifting -- and the table lookup here gives the error. I've also tried member_expression: primary_expression | primary_expression "var" { YYBACKUP(KW_VAR, YYSTYPE()); } | ... which doesn't work, because I cannot back up there, and member_expression: primary_expression | primary_expression error | ... which discards the "var" token. Simon [1] https://github.com/GyrosGeier/test262/commit/e9a33d61ac725b4b353a7a20857f04c7d34fed3d [2] https://es5.github.io/#x7.9 _______________________________________________ help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison