guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Q on (language <lang> spec)


From: Matt Wette
Subject: Re: Q on (language <lang> spec)
Date: Thu, 22 Oct 2015 17:20:57 -0700


On Oct 18, 2015, at 8:53 PM, Nala Ginrut <address@hidden> wrote:
And I'm grad that you write a new lexer generator (before it I only know
silex), it's great! Would you like to make the generated tokens
compatible with scm-lalr? If so, people may rewrite their lexer module
with your lexer generator, and no need to rewrite the parser. I saw the
token name is string rather than symbol, so I guess it's not compatible
with scm-lalr.

Actually, the lexer-generator uses convention of internally turning certain lexemes, like strings, into symbols like ‘$string, or integers into ‘$fixed.  The argument to the lexer-generator is a “match-table” which says how to map the read items quoted items are identifiers (e.g., “while”) or character sequences (e.g., “+=“) to something the parser wants to see.  For example, if you use the symbol WHILE to denote the source text “while” then you would have an entry (“while” . ‘WHILE) in the match table.   So I think the lexer-generator should be adaptable to other parsers.

As as side note, the nyacc parser generator can be “hashified” which means the lexer should return integers.   In that case the match table has entries that look like (“while” . 45).

Matt


reply via email to

[Prev in Thread] Current Thread [Next in Thread]