Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

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

AutoIT C++ script

  • Please log in to reply
22 replies to this topic

#21 Mat

Mat

    43 38 48 31 30 4E 34 4F 32

  • MVPs
  • 4,837 posts

Posted 04 January 2012 - 10:46 AM

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.

{4d696768-744e-6f74-4265-556e69717565}

AutoIt Project Listing







#22 Manadar

Manadar

         

  • MVPs
  • 10,723 posts

Posted 04 January 2012 - 11:14 AM

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.

#23 Mat

Mat

    43 38 48 31 30 4E 34 4F 32

  • MVPs
  • 4,837 posts

Posted 04 January 2012 - 11:29 AM

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


{4d696768-744e-6f74-4265-556e69717565}

AutoIt Project Listing





Also tagged with one or more of these keywords: AutoIT, C++, script

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users