nicer formatting

FossilOrigin-Name: b01735adaf1a9640b7a1ade14effce83de8c90305df1c0f6077b71a6022d90d4
private
alpha 2 years ago
parent 6b083fd884
commit ccf9e0e19c

@ -112,12 +112,14 @@ module Lox
until state.eos?
case
when state.scan(/\/\/(?~\n)/) # ignore line comment
when state.scan(/\/\/(?~\n)/)
# ignore line comment
when state.scan(/\/\*/)
scan_block_comment(state)
when matched = state.scan(TOKENS_RE)
state.add_token(TOKENS.fetch(matched))
when state.scan(/[ \r\t]/) # ignore whitespace
when state.scan(/[ \r\t]/)
# ignore whitespace
when state.scan(/\n/)
state.line += 1
when state.scan(/"/)
@ -127,8 +129,9 @@ module Lox
when identifier = state.scan(/[a-zA-Z_]\w*/)
type = KEYWORDS.fetch(identifier, :IDENTIFIER)
state.add_token(type)
else state.scan(/./) # keep scanning
else
state.errors << Error.new(line: state.line, message: "Unexpected character.")
state.scan(/./) # keep scanning
end
end

Loading…
Cancel
Save