Skip to content

Commit

Permalink
Try to ensure proxy lexers have an initial rule.
Browse files Browse the repository at this point in the history
  • Loading branch information
orbitalquark committed Aug 26, 2023
1 parent 0a8c23d commit 0289532
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lexers/lexer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,12 @@ local function build_grammar(lexer, init_style)
if style_num == init_style then
local lexer_name = tag:match('^whitespace%.(.+)$') or lexer._parent_name or lexer._name
if lexer._initial_rule == lexer_name then break end
if not lexer._grammar_table[lexer_name] then
-- For proxy lexers like RHTML, the 'whitespace.rhtml' tag would produce the 'rhtml'
-- lexer name, but there is no 'rhtml' rule. It should be the 'html' rule (parent)
-- instead.
lexer_name = lexer._parent_name or lexer._name
end
lexer._initial_rule = lexer_name
lexer._grammar_table[1] = lexer._initial_rule
lexer._grammar = Ct(P(lexer._grammar_table))
Expand Down

0 comments on commit 0289532

Please sign in to comment.