Wilfred/bison-mode

char literals with '|' are confusing

Opened this issue · 0 comments

here's the fix, i think:

(defun bison--production-alternative-p (bol eol section)
  "return t if the current line contains a \"|\" used to designate a rule
alternative"
  (save-excursion
    (goto-char bol)
    (if (re-search-forward "[^']|" eol t) ; todo: should also match | at bol
    (not (bison--within-braced-c-expression-p section))
      nil)))

example test case...

rule:
      '|' token1 { /* this matches a literal bar followed by token1 */ |
      | token2 {}
     ;