Skip to content

Commit

Permalink
Make default rule more permissive in YANG lexer (#1488)
Browse files Browse the repository at this point in the history
Although strings of the form `+abc*iu` should be tokenised as correct
by the Yang lexer, they currently produce errors. This commit fixes
this problem by reducing the characters excluded by the default rule.
  • Loading branch information
gribok authored Apr 9, 2020
1 parent 9def927 commit 1d41d2d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rouge/lexers/yang.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def self.types
end
end

rule %r/[^;{}\s*+'"]+/, Name
rule %r/[^;{}\s'"]+/, Name
end
end
end
Expand Down
10 changes: 10 additions & 0 deletions spec/lexers/yang_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@
['Punctuation', ';']
end

it 'parse complex name' do
assert_tokens_equal ' +abc*iu{ asd;}',
['Text.Whitespace', ' '],
['Name', '+abc*iu'],
['Punctuation', '{'],
['Text.Whitespace', ' '],
['Name', 'asd'],
['Punctuation', ';}']
end

end

end
Expand Down

0 comments on commit 1d41d2d

Please sign in to comment.