diff --git a/lib/maxy/gen/tokenizer.rb b/lib/maxy/gen/tokenizer.rb index 0f1b828..955de37 100644 --- a/lib/maxy/gen/tokenizer.rb +++ b/lib/maxy/gen/tokenizer.rb @@ -3,6 +3,7 @@ module Gen class Tokenizer TOKEN_TYPES = [ [:arguments, /({[^{}]*})/], + [:mc_identifier, /(mc\.[^{}()]+~)(?=[-+=*<{}])?/], [:escaped_identifier, /(\\[\S][^-+={}<()\\]*)(?=[-+=*<{}])?/], [:identifier, /([^-+={}<()\\]+)(?=[-+=*<{}])?/], [:oparen, /(\()/], diff --git a/spec/maxy/tokenizer_spec.rb b/spec/maxy/tokenizer_spec.rb index 1634bc9..e41cf38 100644 --- a/spec/maxy/tokenizer_spec.rb +++ b/spec/maxy/tokenizer_spec.rb @@ -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 \ No newline at end of file + + 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