How to write a parser in C?

How would you write a parser/lexer for AppleScript?

  • Is it feasible to write on using YACC, and ANTLR?

  • Answer:

    I don't know a lot about AppleScript, but unless it is seriously weird, I can't imagine you can't write a reasonable parser using conventional parser-generator tools (along with the usual troubles that typical parser generators bring by imposing their limitations (LALR(1), LL(1)) on the grammar you might write). People manage to build parsers with these tools in spite of the glitches. What I can tell you from almost 15 years of experience with a GLR parser generator, is that building parsers even for langauges considered "hard" is relatively straightforward with GLR.  Our DMS Software Reengineering Toolkit has a GLR parser generator, and we parse some 40 languages with it, including C++11 with all the complications of GCC and MS Visual Studio variants without the usual trouble that people building C++ parsers have.  Based on that, I'd expect AppleScript to be relatively easy.

Ira Baxter at Quora Visit the source

Was this solution helpful to you?

Other answers

It's certainly feasible. In fact, YACC was the parser tool used for the earliest versions of AppleScript. Read Bill Cook's fascinating account of early AppleScript development history here: http://www.cs.utexas.edu/~wcook/Drafts/2006/ashopl.pdf As for how I'd go about it, I honestly haven't given much thought, since it's not exactly one of my favorite languages.

Adrian Ho

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.