|Parsing a simple BASIC language firstname.lastname@example.org (paul.dunn4) (2001-04-04)|
|Re: Parsing a simple BASIC language email@example.com (Barry Kelly) (2001-04-10)|
|Re: Parsing a simple BASIC language firstname.lastname@example.org (2001-04-10)|
|Re: Parsing a simple BASIC language email@example.com (2001-04-12)|
|Re: Parsing a simple BASIC language firstname.lastname@example.org (Dunny) (2001-04-12)|
|Re: Parsing a simple BASIC language email@example.com (Barry Kelly) (2001-04-14)|
|Re: Parsing a simple BASIC language firstname.lastname@example.org (2001-04-18)|
|Re: Parsing a simple BASIC language email@example.com (2001-04-18)|
|Re: Parsing a simple BASIC language firstname.lastname@example.org (Dunny) (2001-04-22)|
|Re: Parsing a simple BASIC language email@example.com (Barry Kelly) (2001-04-22)|
|From:||firstname.lastname@example.org (Timon Christl)|
|Date:||12 Apr 2001 02:43:09 -0400|
|Posted-Date:||12 Apr 2001 02:43:09 EDT|
On 10 Apr 2001 01:15:43 -0400, Barry Kelly wrote
>I'm not familiar with Sinclair Basic, but I have written many parsers
>in Object Pascal (Delphi). Might I suggest that you use a simple
>recursive descent parser (and change your grammar to LL(1), with
>context if necessary), and begin highlighting in red at the beginning
>of the first invalid token found by the parser?
I'm also writing a Scanner and Parser in Delphi, and want to contribute
my experience. It's my first serious attempt at a parser, so I use a
recursive descendant one to parse a small toy-language (basicallymixture of
C and Pascal . But I chose not to use a LL(1) grammar because
I have to look ahead two tokens in some productions. I use a small
fixed-size token stack to buffer the token stream so it's as fast as it
can get. Of course I could do a LL(1) grammar but why making the grammar
harder to read when this way works and is fast enough?
>For speed, the method I have found to work efficiently with Object
>Pascal, for lexical analysis, looks like this; It uses a little hack,
>similar to Classes.pas's TParser, which defines TToken as a character;
>this makes it easy to use for ':', ';' etc:
Yes, it is faster than my approach, but mine is definitely cleaner.
I use something like the record below for my tokens which greatly
aides to make a decent error reporting, which I miss with some
compilers out there.
>One final note for speed; make sure you're using a hash table for lookup.
>I've got a fairly fast hashtable on
I'm going to give it a try, since my own hash table implementation sucks
pretty much, as it was written in about half an hour. Btw, is there
something like gperf for pascal?
Timon Christl <email@example.com>
Return to the
Search the comp.compilers archives again.