Skip to content
This repository has been archived by the owner on Jul 23, 2022. It is now read-only.

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

Closed
rain-1 opened this issue Mar 2, 2018 · 11 comments
Closed

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

rain-1 opened this issue Mar 2, 2018 · 11 comments
Assignees

Comments

@rain-1
Copy link

rain-1 commented Mar 2, 2018

#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
Copy link
Owner

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"

@mbutterick
Copy link
Owner

mbutterick commented Mar 2, 2018

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")

@mbutterick mbutterick self-assigned this Mar 2, 2018
@mbutterick
Copy link
Owner

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
Copy link
Owner

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.

@rain-1
Copy link
Author

rain-1 commented Mar 3, 2018

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
Copy link
Owner

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
Copy link
Owner

(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
Copy link
Author

rain-1 commented Mar 3, 2018

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
Copy link
Owner

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
Copy link
Author

rain-1 commented Mar 3, 2018

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

mbutterick added a commit that referenced this issue Mar 3, 2018
@mbutterick
Copy link
Owner

OK, fixed that

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants