cannot parse words "start", "error", "atok" #3

Closed
opened 6 years ago by rain-1 · 11 comments
rain-1 commented 6 years ago (Migrated from github.com)
#lang brag
foo   : "start"

.racket/6.12/pkgs/brag/brag/cfg-parser/cfg-parser.rkt:708:55: parser-non-terminals: start used as both token and non-terminal in: start

``` #lang brag foo : "start" ``` .racket/6.12/pkgs/brag/brag/cfg-parser/cfg-parser.rkt:708:55: parser-non-terminals: start used as both token and non-terminal in: start
mbutterick commented 6 years ago (Migrated from github.com)

I see what you mean. This is a bug in the underlying ragg code (which I didn’t write) so it will take me some time to figure it out. In the meantime, you can probably work around by specifying the rule like so?

#lang brag
foo : "star" "t"
I see what you mean. This is a bug in the underlying `ragg` code (which I didn’t write) so it will take me some time to figure it out. In the meantime, you can probably work around by specifying the rule like so? ```racket #lang brag foo : "star" "t" ```
mbutterick commented 6 years ago (Migrated from github.com)

Actually, that won’t work.

Here’s a better idea (this time I’m trying it before writing it). Instead of passing the raw string "start" (or "error" or "atok") as a token, edit your lexer to package each into a named token structure, e.g., (token 'START "start"). Then you can change the grammar to refer to this named token:

;; parse.rkt
#lang brag
foo   : START

This will parse the same way, and the underlying string will end up the parse tree:

#lang br
(require "parse.rkt" brag/support)
(parse-to-datum (list (token 'START "start")))
'(foo "start")
Actually, that won’t work. Here’s a better idea (this time I’m trying it before writing it). Instead of passing the raw string `"start"` (or `"error"` or `"atok"`) as a token, edit your lexer to package each into a named token structure, e.g., `(token 'START "start")`. Then you can change the grammar to refer to this named token: ``` ;; parse.rkt #lang brag foo : START ``` This will parse the same way, and the underlying string will end up the parse tree: ```racket #lang br (require "parse.rkt" brag/support) (parse-to-datum (list (token 'START "start"))) ``` ``` '(foo "start") ```
mbutterick commented 6 years ago (Migrated from github.com)

Note to self: check if this is an insurmountable restriction of the underlying cfg-parser function. If so, the only “fix” is to amend the docs with a list of reserved words.

Note to self: check if this is an insurmountable restriction of the underlying `cfg-parser` function. If so, the only “fix” is to amend the docs with a list of reserved words.
mbutterick commented 6 years ago (Migrated from github.com)

I was able to rehabilitate "start" and "atok" as literal tokens. But according to the br-parser-tools docs, “A token cannot be named error, since error it has special use in the parser.” I’ve also updated the brag docs to note this.

I was able to rehabilitate `"start"` and `"atok"` as literal tokens. But [according to the `br-parser-tools` docs]( https://docs.racket-lang.org/br-parser-tools/Lexers.html?q=cfg-parser#%28form._%28%28lib._br-parser-tools%2Flex..rkt%29._define-tokens%29%29), “A token cannot be named `error`, since `error` it has special use in the parser.” I’ve also updated the `brag` docs to note this.
rain-1 commented 6 years ago (Migrated from github.com)

Thanks for looking into this.

I git cloned the latest and tried cd brag ; raco pkg install but I got a lot of errors. If I cd brag and do raco test . i get some files running then brag/brag/brag.scrbl:6:21: cannot open module file module path: brag/support failure.

How should I test this latest commit?


raco setup: error: during making for <pkgs>/brag/brag/brag/test
raco setup:   brag/brag/test/test-parser.rkt:6:9: collection not found
raco setup:     for module path: brag/rules/parser
raco setup:     collection: "brag/rules"

standard-module-name-resolver: collection not found
  for module path: brag/rules/rule-structs
  collection: "brag/rules"
  in collection directories:
   /home/ivy/.racket/6.12/collects
   /usr/share/racket/collects
Thanks for looking into this. I git cloned the latest and tried cd brag ; raco pkg install but I got a lot of errors. If I cd brag and do raco test . i get some files running then `brag/brag/brag.scrbl:6:21: cannot open module file module path: brag/support` failure. How should I test this latest commit? -------------- ``` raco setup: error: during making for <pkgs>/brag/brag/brag/test raco setup: brag/brag/test/test-parser.rkt:6:9: collection not found raco setup: for module path: brag/rules/parser raco setup: collection: "brag/rules" standard-module-name-resolver: collection not found for module path: brag/rules/rule-structs collection: "brag/rules" in collection directories: /home/ivy/.racket/6.12/collects /usr/share/racket/collects ```
mbutterick commented 6 years ago (Migrated from github.com)

I’m not sure a direct git clone will work, because this repo holds a multi-collection package. Better to use raco pkg update brag.

I’m not sure a direct `git clone` will work, because this repo holds a multi-collection package. Better to use `raco pkg update brag`.
mbutterick commented 6 years ago (Migrated from github.com)

(BTW I can’t reproduce these errors locally, nor do they show up on Travis, which heightens my suspicion that the git clone technique is the problem)

(BTW I can’t reproduce these errors locally, nor do they show up on Travis, which heightens my suspicion that the `git clone` technique is the problem)
rain-1 commented 6 years ago (Migrated from github.com)

I tried raco pkg update brag but it got me the latest release from racket pkgs which seems to be before this latest git commit with the "start" fix.

I tried `raco pkg update brag` but it got me the latest release from racket pkgs which seems to be before this latest git commit with the "start" fix.
mbutterick commented 6 years ago (Migrated from github.com)

You can also do raco pkg install https://github.com/mbutterick/brag.git?path=brag if the package server isn’t going fast enough

You can also do `raco pkg install https://github.com/mbutterick/brag.git?path=brag` if the package server isn’t going fast enough
rain-1 commented 6 years ago (Migrated from github.com)

thanks a lot that worked, I see that I can use "start" now but not "%start".

thanks a lot that worked, I see that I can use "start" now but not "%start".
mbutterick commented 6 years ago (Migrated from github.com)

OK, fixed that

OK, fixed that
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mbutterick/brag#3
Loading…
There is no content yet.