spec/support/base_tokenizer_spec.rb in rley-0.7.00 vs spec/support/base_tokenizer_spec.rb in rley-0.7.01

- old
+ new

@@ -25,25 +25,23 @@ context 'Provided services:' do class PB_Tokenizer < BaseTokenizer @@lexeme2name = { '(' => 'LPAREN', ')' => 'RPAREN', - '+' => 'PLUS', + '+' => 'PLUS' }.freeze protected def recognize_token() - token = nil - if (lexeme = scanner.scan(/[\(\)]/)) # Single characters # Delimiters, separators => single character token - token = build_token(@@lexeme2name[lexeme], lexeme) - elsif (lexeme = scanner.scan(/(?:\+)(?=\s)/)) # Single char occurring alone - token = build_token(@@lexeme2name[lexeme], lexeme) - elsif (lexeme = scanner.scan(/[+-]?[0-9]+/)) - token = build_token('int', lexeme) + build_token(@@lexeme2name[lexeme], lexeme) + elsif (lexeme = scanner.scan(/(?:\+)(?=\s)/)) # Isolated char + build_token(@@lexeme2name[lexeme], lexeme) + elsif (lexeme = scanner.scan(/[+-]?[0-9]+/)) + build_token('int', lexeme) end end end # class # Basic tokenizer @@ -72,6 +70,6 @@ expect(token.position.line).to eq(line) expect(token.position.column).to eq(col) end end end -end # describe \ No newline at end of file +end # describe