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

Supress warnings during parsing #1013

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/parser/builders/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2263,7 +2263,12 @@ def static_regexp(parts, options)
source
end

Regexp.new(source, (Regexp::EXTENDED if options.children.include?(:x)))
begin
old_verbose, $VERBOSE = $VERBOSE, nil
Regexp.new(source, (Regexp::EXTENDED if options.children.include?(:x)))
ensure
$VERBOSE = old_verbose
end
end

def static_regexp_node(node)
Expand Down
17 changes: 13 additions & 4 deletions lib/parser/lexer.rl
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,23 @@ class Parser::Lexer
@emit_integer_if = lambda { |chars, p| emit(:tINTEGER, chars, @ts, @te - 2); p - 2 }
@emit_integer_rescue = lambda { |chars, p| emit(:tINTEGER, chars, @ts, @te - 6); p - 6 }

@emit_float = lambda { |chars, p| emit(:tFLOAT, Float(chars)); p }
@emit_imaginary_float = lambda { |chars, p| emit(:tIMAGINARY, Complex(0, Float(chars))); p }
@emit_float_if = lambda { |chars, p| emit(:tFLOAT, Float(chars), @ts, @te - 2); p - 2 }
@emit_float_rescue = lambda { |chars, p| emit(:tFLOAT, Float(chars), @ts, @te - 6); p - 6 }
@emit_float = lambda { |chars, p| emit(:tFLOAT, construct_float(chars)); p }
@emit_imaginary_float = lambda { |chars, p| emit(:tIMAGINARY, Complex(0, construct_float(chars))); p }
@emit_float_if = lambda { |chars, p| emit(:tFLOAT, construct_float(chars), @ts, @te - 2); p - 2 }
@emit_float_rescue = lambda { |chars, p| emit(:tFLOAT, construct_float(chars), @ts, @te - 6); p - 6 }

reset
end

def construct_float(chars)
begin
old_verbose, $VERBOSE = $VERBOSE, nil
Float(chars)
ensure
$VERBOSE = old_verbose
end
end

def reset(reset_state=true)
# Ragel state:
if reset_state
Expand Down
Loading