lib/import/shake_grammar/lexer.rb in tracksperanto-1.7.4 vs lib/import/shake_grammar/lexer.rb in tracksperanto-1.7.5
- old
+ new
@@ -10,10 +10,12 @@
# Access to the sentinel object
attr_reader :sentinel
STOP_TOKEN = :__stop #:nodoc:
+ MAX_BUFFER_SIZE = 32000
+ MAX_STACK_DEPTH = 127
# The first argument is the IO handle to the data of the Shake script.
# The second argument is a "sentinel" that is going to be passed
# to the downstream lexers instantiated for nested data structures.
# You can use the sentinel to collect data from child nodes for example.
@@ -40,14 +42,14 @@
def parse
c = @io.read(1)
- if @buf.length > 32000 # Wrong format and the buffer is filled up, bail
+ if @buf.length > MAX_BUFFER_SIZE # Wrong format and the buffer is filled up, bail
raise WrongInput, "Buffer overflow at 32K, this is definitely not a Shake script"
end
- if @stack_depth > 127 # Wrong format - parentheses overload
+ if @stack_depth > MAX_STACK_DEPTH # Wrong format - parentheses overload
raise WrongInput, "Stack overflow at level 128, this is probably a LISP program uploaded by accident"
end
return consume_comment(c) if in_comment?
\ No newline at end of file