Skip to content

Commit

Permalink
Introduce mc_identifier token type #13
Browse files Browse the repository at this point in the history
  • Loading branch information
julianrubisch committed Mar 23, 2019
1 parent 96f9325 commit 8b1052a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/maxy/gen/tokenizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Gen
class Tokenizer
TOKEN_TYPES = [
[:arguments, /({[^{}]*})/],
[:mc_identifier, /(mc\.[^{}()]+~)(?=[-+=*<{}])?/],
[:escaped_identifier, /(\\[\S][^-+={}<()\\]*)(?=[-+=*<{}])?/],
[:identifier, /([^-+={}<()\\]+)(?=[-+=*<{}])?/],
[:oparen, /(\()/],
Expand Down
8 changes: 7 additions & 1 deletion spec/maxy/tokenizer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,10 @@
expect(tokens.map(&:type)).to eq(%i[identifier arguments less_than identifier arguments])
expect(tokens.map(&:value)).to eq(%w[int {3} < pack {1\ 2\ 3}])
end
end

it 'should tokenize an mc chain' do
tokens = Tokenizer.new('mc.cycle~{400}-mc.+~{0.1}').tokenize
expect(tokens.map(&:type)).to eq(%i[mc_identifier arguments dash mc_identifier arguments])
expect(tokens.map(&:value)).to eq(%w[mc.cycle~ {400} - mc.+~ {0.1}])
end
end

0 comments on commit 8b1052a

Please sign in to comment.