Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lexer datastudio #1453

Merged
merged 8 commits into from
Mar 31, 2020
Prev Previous commit
Next Next commit
allow nesting of variables in strings
  • Loading branch information
BastienDurel committed Mar 6, 2020
commit 1f0366775f1e39cf7119d70214b2ad26d0b145ee
18 changes: 15 additions & 3 deletions lib/rouge/lexers/datastudio.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,27 @@ class Datastudio < RegexLexer
rule %r(/[*].*?[*]/)m, Comment::Multiline
pyrmont marked this conversation as resolved.
Show resolved Hide resolved
end

state :string do
rule %r/%(\\.|.)+?%/, Str::Escape
rule %r/"/, Str, :pop!
rule %r/./, Str
end

state :string_s do
rule %r/%(\\.|.)+?%/, Str::Escape
rule %r/'/, Str, :pop!
rule %r/./, Str
end

state :root do
mixin :whitespace

rule %r/^:#{id}/, Name::Label
rule %r/@#{id}(\.#{id})?/m, Name::Entity
rule %r/%(\\.|.)*?%/, Name::Variable
rule %r/%(\\.|.)+?%/, Name::Variable
rule %r/[~!%^&*()+=|\[\]{}:;,.<>\/?-]/, Punctuation
rule %r/"(\\.|.|\n)*?"/, Str
rule %r/'(\\.|.|\n)*?'/, Str
rule %r/"(\\.|.|\n)*?/, Str, :string
rule %r/'(\\.|.|\n)*?/, Str, :string_s
rule %r(
[0-9]
([.][0-9]*)? # decimal
Expand Down