Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

There is a easy way to ignore whitespace? #24

Closed
geovanisouza92 opened this Issue · 4 comments

3 participants

@geovanisouza92

Hi!

I'm writing my grammar using treetop, for a new programming language (prototype for while), but I cannot found a way to ignore whitespace/comments assertively.

There's an feature in tool, or will be implemented soon?

@geovanisouza92

I'm tried modify the source code, and I imagine something like

in treetop/runtime/compiled_parser.rb

  def has_terminal?(terminal, regex, index)
    # FIXME: Enable to ignore tabs and newlines (separated)
    if @ignore_whitespace
      index += 1 if input[index] == " "
    end
    if regex
      rx = @regexps[terminal] ||= Regexp.new(terminal)
      input.index(rx, index) == index
    else
      input[index, terminal.size] == terminal
    end
  end

And include an '-w/--ignore-whitespace' option in 'tt' binary...

Some ideas/comments?

@presidentbeef

You could just gsub(/\s/, "") your source before parsing it?

@cjheath
Collaborator
@cjheath
Collaborator
@cjheath cjheath closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.