Re: [racket-users] br-parser-tools question

2020-06-09 Thread jon stenerson
I don't think you should assume I have a *good* reason for using yacc 
over brag. I just thought that in my case it would be easier to put some 
code in the productions rather than build a full parse tree and then 
process that. I seem to have been wrong about that. I will take another 
look at brag.


On 6/8/2020 11:00 PM, Matthew Butterick wrote:
`br-parser-tools` has some patches needed to make `brag` work, e.g., 
using the srcloc structure. I forked rather than patch the underlying 
`parser-tools` package because I didn't want to destroy the fragile 
ancient artifact. I fixed a few bugs; the others persist. I notice, 
for example, that your program fails to work regardless of whether it 
uses `br-parser-tools` or `parser-tools`. (I'm assuming here you have 
a good reason to use good old `yacc` and not `brag`, which does mostly 
the same thing, less painfully)


On 08 Jun 20, at 9:29 PM, Jon Stenerson > wrote:


Thanks for confirming. I had actually started with the lexer-src-pos 
version but had other problems like exn:fail:read wanting a list of 
srclocs and the lexer only having positions. So I switched to 
lexer-srcpos which fixed the exception but broke the parse. Maybe I 
should do a conversion between positions and srclocs at some point? 
Seems awkward.




--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/f4279184-e314-6016-cbb8-ce4f212dfb46%40comcast.net.


Re: [racket-users] br-parser-tools question

2020-06-08 Thread Matthew Butterick
`br-parser-tools` has some patches needed to make `brag` work, e.g., using the 
srcloc structure. I forked rather than patch the underlying `parser-tools` 
package because I didn't want to destroy the fragile ancient artifact. I fixed 
a few bugs; the others persist. I notice, for example, that your program fails 
to work regardless of whether it uses `br-parser-tools` or `parser-tools`. (I'm 
assuming here you have a good reason to use good old `yacc` and not `brag`, 
which does mostly the same thing, less painfully)

> On 08 Jun 20, at 9:29 PM, Jon Stenerson  wrote:
> 
> Thanks for confirming. I had actually started with the lexer-src-pos version 
> but had other problems like exn:fail:read wanting a list of srclocs and the 
> lexer only having positions. So I switched to lexer-srcpos which fixed the 
> exception but broke the parse. Maybe I should do a conversion between 
> positions and srclocs at some point? Seems awkward.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/AB46325E-0B78-4ACE-82AD-B5F5AFA4F57E%40mbtype.com.


Re: [racket-users] br-parser-tools question

2020-06-08 Thread Jon Stenerson
Thanks for confirming. I had actually started with the lexer-src-pos version 
but had other problems like exn:fail:read wanting a list of srclocs and the 
lexer only having positions. So I switched to lexer-srcpos which fixed the 
exception but broke the parse. Maybe I should do a conversion between positions 
and srclocs at some point? Seems awkward.

On June 8, 2020, at 6:49 PM, Jon Zeppieri  wrote:

On Mon, Jun 8, 2020 at 8:36 PM jon stenerson  wrote:
>
> Hi all,
>
> I don't understand the error message here. The parser seems to be
> looking for a position-token but the lexer is sending srcloc-tokens? Is
> there a simple fix? Using Racket 7.7 on WIn 10.

Hi Jon,

Yes, you're right, and there is a simple fix. Instead of using
`lexer-srcloc`, you can use `lexer-src-pos`. The former seems to be an
addition to the `br-` variant of parser-tools, but I don't see any
indication that the lexers it generates can be used with the yacc
tools. (I could be wrong about that.)

- Jon

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/1gkb5qug6ffe8copwx6u8cc1.1591676950009%40email.android.com.


Re: [racket-users] br-parser-tools question

2020-06-08 Thread Jon Zeppieri
On Mon, Jun 8, 2020 at 8:36 PM jon stenerson  wrote:
>
> Hi all,
>
> I don't understand the error message here. The parser seems to be
> looking for a position-token but the lexer is sending srcloc-tokens? Is
> there a simple fix? Using Racket 7.7 on WIn 10.

Hi Jon,

Yes, you're right, and there is a simple fix. Instead of using
`lexer-srcloc`, you can use `lexer-src-pos`. The former seems to be an
addition to the `br-` variant of parser-tools, but I don't see any
indication that the lexers it generates can be used with the yacc
tools. (I could be wrong about that.)

- Jon

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAKfDxxyi_ubBaRhs%3DHD9R7UxTYmePqqVLbsbOFcHzg8%2BQfR1KQ%40mail.gmail.com.


[racket-users] br-parser-tools question

2020-06-08 Thread jon stenerson

Hi all,

I don't understand the error message here. The parser seems to be 
looking for a position-token but the lexer is sending srcloc-tokens? Is 
there a simple fix? Using Racket 7.7 on WIn 10.


I am also confused about whether to use br-parser-tools or parser-tools 
package. br-* is the more recent?


Thanks,

Jon


#lang racket

(require br-parser-tools/lex)
(require br-parser-tools/yacc)

(define-empty-tokens etoks (ZERO ONE EOF))

(define simple-lex
  (lexer-srcloc
   ["0" (token-ZERO)]
   ["1" (token-ONE)]
   [(eof) (token-EOF)]
   ))


(define (err-proc tok-ok? tok-name tok-value start-pos end-pos)
  (display "Ugghh!"))

(define simple-parse
  (parser
   (tokens etoks)
   (start S)
   (end EOF)
   (src-pos)
   (error err-proc)
   (grammar
    (S [(ONE ZERO) 'OK])
    )))


(define (make-scanner ip [path #f])
  (λ () (simple-lex ip)))

(simple-parse (make-scanner (open-input-string "01")))

--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/6a0f7471-86f2-b889-0c8c-fdc400dfeb87%40comcast.net.