Skip to content

Conversation

@Earlopain
Copy link
Collaborator

  • Current bin/prism lex becomes bin/prism lex_compat
  • Change bin/prism lex to only output prism tokens

I sometimes find myself wanting to look at tokens but on the cli it only compares against other sources. Then I check the code and see that that VERBOSE=1 does something but the output isn't very readable and doesn't fit on my terminal screen.

The new output looks like this:

$ bin/prism lex -e "foo(1, BAR, baz, 'bat')"
IDENTIFIER        (1,0)-(1,3) "foo"
PARENTHESIS_LEFT  (1,3)-(1,4) "("
INTEGER           (1,4)-(1,5) "1"
COMMA             (1,5)-(1,6) ","
CONSTANT          (1,7)-(1,10) "BAR"
COMMA             (1,10)-(1,11) ","
IDENTIFIER        (1,12)-(1,15) "baz"
COMMA             (1,15)-(1,16) ","
STRING_BEGIN      (1,17)-(1,18) "'"
STRING_CONTENT    (1,18)-(1,21) "bat"
STRING_END        (1,21)-(1,22) "'"
PARENTHESIS_RIGHT (1,22)-(1,23) ")"
EOF               (1,23)-(1,23) ""

* Current `bin/prism lex` becomes `bin/prism lex_compat`
* Change `bin/prism lex` to only output prism tokens

I sometimes find myself wanting to look at tokens but on the cli
it only compares against other sources. Then I check the code and see that that `VERBOSE=1`
does something but the output isn't very readable
and doesn't fit on my terminal screen.

The new output looks like this:
```
$ bin/prism lex -e "foo(1, BAR, baz, 'bat')"
IDENTIFIER        (1,0)-(1,3) "foo"
PARENTHESIS_LEFT  (1,3)-(1,4) "("
INTEGER           (1,4)-(1,5) "1"
COMMA             (1,5)-(1,6) ","
CONSTANT          (1,7)-(1,10) "BAR"
COMMA             (1,10)-(1,11) ","
IDENTIFIER        (1,12)-(1,15) "baz"
COMMA             (1,15)-(1,16) ","
STRING_BEGIN      (1,17)-(1,18) "'"
STRING_CONTENT    (1,18)-(1,21) "bat"
STRING_END        (1,21)-(1,22) "'"
PARENTHESIS_RIGHT (1,22)-(1,23) ")"
EOF               (1,23)-(1,23) ""
```
Copy link
Collaborator

@kddnewton kddnewton left a comment

Choose a reason for hiding this comment

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

Nice

@kddnewton kddnewton merged commit a6f7e60 into ruby:main Nov 5, 2025
62 checks passed
@Earlopain Earlopain deleted the bin-prism-lex branch December 3, 2025 07:36
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