Skip to content
This repository has been archived by the owner on Sep 8, 2023. It is now read-only.

Commit

Permalink
Make default rule more permissive in YANG lexer (rouge-ruby#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 and mattt committed May 21, 2020
1 parent 761ddc0 commit 7e2dc18
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 7e2dc18

Please sign in to comment.