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

Improve readability of lexer debug outputs #1240

Merged
merged 2 commits into from
Jul 2, 2019

Conversation

ashmaroli
Copy link
Contributor

@ashmaroli ashmaroli commented Jul 1, 2019

Before

start blocks
    pushing :expr_start
lexer: ruby
stack: [:root, :expr_start]
stream: "#######\n# ruby 1.9 e"
  entering mixin inline_whitespace
  trying #<Rule /[ \t\r]+/>
  exiting  mixin inline_whitespace
  trying #<Rule /\//>
  trying #<Rule /
          [?](\\[MC]-)*     # modifiers
          (\\([\\abefnrstv\#"']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})|\S)
          (?!\w)
        /x>
  trying #<Rule /(\s*)(%[rqswQWxiI]? \S* )/>
  entering mixin sigil_strings
  trying #<Rule /%([rqswQWxiI])?([^\w\s])/>
  exiting  mixin sigil_strings
  trying #<Rule //>
    got ""
    popping stack: 1
lexer: ruby
stack: [:root]
stream: "#######\n# ruby 1.9 e"
  entering mixin whitespace
  entering mixin inline_whitespace
  trying #<Rule /[ \t\r]+/>
  exiting  mixin inline_whitespace
  trying #<Rule /\n\s*/m>
  trying #<Rule /#.*$/>
    got "#######"
    yielding Comment.Single, "#######"
lexer: ruby
stack: [:root]
stream: "\n# ruby 1.9 examples"
  entering mixin whitespace
  entering mixin inline_whitespace
  trying #<Rule /[ \t\r]+/>
  exiting  mixin inline_whitespace
  trying #<Rule /\n\s*/m>
    got "\n"
    yielding Text, "\n"
    pushing :expr_start

After

start blocks
    pushing: :expr_start

lexer: ruby
stack: [:root, :expr_start]
stream: "#######\n# ruby 1.9 e"
  entering: mixin :inline_whitespace
  trying: #<Rule /[ \t\r]+/>
  exiting:  mixin :inline_whitespace
  trying: #<Rule /\//>
  trying: #<Rule /
          [?](\\[MC]-)*     # modifiers
          (\\([\\abefnrstv\#"']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})|\S)
          (?!\w)
        /x>
  trying: #<Rule /(\s*)(%[rqswQWxiI]? \S* )/>
  entering: mixin :sigil_strings
  trying: #<Rule /%([rqswQWxiI])?([^\w\s])/>
  exiting:  mixin :sigil_strings
  trying: #<Rule //>
    got: ""
    popping stack: 1

lexer: ruby
stack: [:root]
stream: "#######\n# ruby 1.9 e"
  entering: mixin :whitespace
  entering: mixin :inline_whitespace
  trying: #<Rule /[ \t\r]+/>
  exiting:  mixin :inline_whitespace
  trying: #<Rule /\n\s*/m>
  trying: #<Rule /#.*$/>
    got: "#######"
    yielding: Comment.Single, "#######"

lexer: ruby
stack: [:root]
stream: "\n# ruby 1.9 examples"
  entering: mixin :whitespace
  entering: mixin :inline_whitespace
  trying: #<Rule /[ \t\r]+/>
  exiting:  mixin :inline_whitespace
  trying: #<Rule /\n\s*/m>
    got: "\n"
    yielding: Text, "\n"
    pushing :expr_start

@pyrmont pyrmont added the needs-review The PR needs to be reviewed label Jul 1, 2019
Copy link
Contributor

@pyrmont pyrmont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ashmaroli More of a wider question:

lib/rouge/regex_lexer.rb Outdated Show resolved Hide resolved
@pyrmont pyrmont added author-action The PR has been reviewed but action by the author is needed and removed needs-review The PR needs to be reviewed labels Jul 2, 2019
@pyrmont pyrmont merged commit c56e788 into rouge-ruby:master Jul 2, 2019
@pyrmont pyrmont removed the author-action The PR has been reviewed but action by the author is needed label Jul 2, 2019
@ashmaroli ashmaroli deleted the improve-debug-output branch July 3, 2019 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants