Jump to content

Experimental (Academic) AutoIT Script Interpreter [C++]


Recommended Posts

The point is not to not use stacks.

Also, inb4 pratt parser.

It does use a THE stack, as it relies heavily on recursion :) I did write a non recursive version using a stack for assembly as well. I guess what you mean to say is that it is better to not maintain a stack explicitly.

However, since all AutoIt statements have signal tokens (e.g. there is some unique token at the start of every statement: switch, select, while, for, do, func...), A predictive parser is probably the right way to go. Pratt's is more suited to maths expressions, its main strength being resolving ambiguity easily, allowing it to be easily extended.

Reading through my textbook now, most of the algorithms are stack and table driven (or recursive descent). I definitely think you could do better than having two separate parsers though. That does not make much sense.

Link to comment
Share on other sites

It does use a THE stack, as it relies heavily on recursion :) I did write a non recursive version using a stack for assembly as well. I guess what you mean to say is that it is better to not maintain a stack explicitly.

I didn't mean to say better or worse, really. My "The point is not to not use stacks" was aimed at the fact that because of the usage of recursion to drive the algorithm you are using a stack anyway. You can't really do without a stack (or table as you said).

I agree with the rest of your post. Didn't read his code so wouldn't know about two parsers, but I can see the merit in two parsing strategies. If you use a method where you parse BNF and produce a parser that way, you are using two parsers. But again I say, I didn't read his code.

Link to comment
Share on other sites

I didn't mean to say better or worse, really. My "The point is not to not use stacks" was aimed at the fact that because of the usage of recursion to drive the algorithm you are using a stack anyway. You can't really do without a stack (or table as you said).

Ah right, I misread your post. I guess when you are talking about C++, the standard does not define HOW the function call stack should be implement it... It could be a singly linked list quite easily (linked backwards though) so then it wouldn't be a stack at all, so I guess when you are writing in a language that deals with a standard rather than a platform it is not quite right to say recursion uses a stack. Then again, I have never read the standard, I am guessing that they standardise behaviour not implementation.

I agree with the rest of your post. Didn't read his code so wouldn't know about two parsers, but I can see the merit in two parsing strategies. If you use a method where you parse BNF and produce a parser that way, you are using two parsers. But again I say, I didn't read his code.

I didn't either, but he said he was using:

-Stateful Recursive Decent Parser

-Shunting yard algorithm for expression evaluation

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...