lezer-parser/lezer

PHP conflicts with Parcel watch mode: probably worth adding `require` to `KEYWORDS`

ashmind opened this issue · 0 comments

When running Parcel (a bundler) in watch mode, I got an error

Uncaught SyntaxError: Identifier 'require' has already been declared

on this line from @lezer/php

// This file was generated by lezer-generator. You probably shouldn't edit it.
const castOpen = 1, HeredocString = 2, interpolatedStringContent = 263, EscapeSequence = 3, afterInterpolation = 264, automaticSemicolon = 265, eof = 266, abstract = 4, and = 5, array = 6, as = 7, Boolean = 8, _break = 9, _case = 10, _catch = 11, clone = 12, _const = 13, _continue = 14, _default = 15, declare = 16, _do = 17, echo = 18, _else = 19, elseif = 20, enddeclare = 21, endfor = 22, endforeach = 23, endif = 24, endswitch = 25, endwhile = 26, _enum = 27, _extends = 28, final = 29, _finally = 30, fn = 31, _for = 32, foreach = 33, from = 34, _function = 35, global = 36, goto = 37, _if = 38, _implements = 39, include = 40, include_once = 41, _instanceof = 42, insteadof = 43, _interface = 44, list = 45, match = 46, namespace = 47, _new = 48, _null = 49, or = 50, print = 51, require = 52, require_once = 53, _return = 54, _switch = 55, _throw = 56, trait = 57, _try = 58, unset = 59, use = 60, _var = 61, Visibility = 62, _while = 63, xor = 64, _yield = 65;

It might be that Parcel should handle this better, but given require does have a special meaning in JS ecosystems, it might be safer to add it to KEYWORDS in generator (build.ts#L1988), and have it generated as _require.

I'll try to do a PR soon-ish.