|Parsing a simple BASIC language email@example.com (paul.dunn4) (2001-04-04)|
|Re: Parsing a simple BASIC language firstname.lastname@example.org (Barry Kelly) (2001-04-10)|
|Re: Parsing a simple BASIC language email@example.com (2001-04-10)|
|Re: Parsing a simple BASIC language firstname.lastname@example.org (2001-04-12)|
|Re: Parsing a simple BASIC language email@example.com (Dunny) (2001-04-12)|
|Re: Parsing a simple BASIC language firstname.lastname@example.org (Barry Kelly) (2001-04-14)|
|Re: Parsing a simple BASIC language email@example.com (2001-04-18)|
|Re: Parsing a simple BASIC language firstname.lastname@example.org (2001-04-18)|
|Re: Parsing a simple BASIC language email@example.com (Dunny) (2001-04-22)|
|[1 later articles]|
|Date:||10 Apr 2001 01:29:17 -0400|
|Organization:||Eindhoven University of Technology, The Netherlands|
|Posted-Date:||10 Apr 2001 01:29:17 EDT|
On 4 Apr 2001 00:18:06 -0400, paul.dunn4 <firstname.lastname@example.org> wrote:
> The parser performs the following steps to parse:
> 1) tokenises the input string to Keywords (and function names), and
>types (numerics, strings, symbols) into a stack.
A stack might not be the most appropriate data type, since it seems
that you do not approach the data Last In, First Out. Consider using
some other data type, e.g. an an array.
Of course, another question is how efficient your tokenizing
> 2) runs the resulting stack through the rule reducer to reduce
> all the expressions to their base types (numexpr, stringexpr etc)
You do this before parsing? This is a strange approach, which I do not
> 3) runs the resulting (smaller) stack through the BNF parser using the
>rule for that keyword. It is this part that performs error checking.
Is this a hand-coded parser? Perhaps you wrote a parser that
backtracks when confronted with something it cannot handle? Such a
parser can be very slow, if it has to do lots of backtracking.
Consider using a parser generator tool, or try to rewrite your parser
so that it doesn't do any backtracking.
>1) How to parse a simple BASIC language (like Sinclair Basic) quickly,
I think there is a Lex/Yacc for Object Pascal.
>2) Any better method than the one I'm using here. I used BNF for everything,
>but that was even slower than the method I am using.
I think your parser is not efficient. You can ditch the second step
once you have an efficient parser.
Another idea is to only do the syntax checking in the "idle" loop of
your application. In this way, when the user starts to type a line, it
will not be syntax checked until the computer has time to catch up
with the user.
ir. Stephan H.M.J. Houben
tel. +31-40-2474358 / +31-40-2743497
Return to the
Search the comp.compilers archives again.