Re: OT: Book or Website suggestion please
Re: OT: Book or Website suggestion please
- Subject: Re: OT: Book or Website suggestion please
- From: Andy Lee <email@hidden>
- Date: Sun, 01 Feb 2009 00:50:51 -0500
On Jan 31, 2009, at 11:35 PM, mark wrote:
I want to write a very simple scripting language for a custom
application.
But I haven't looked at language implementation since university a
LONG time ago.
Can anyone suggest a good book (or link).
Bearing in mind that I'm not an expert on this stuff...
Offhand, some concepts I can think of that you'll want to understand
are:
* tokenizing
* context-free grammars
* parse trees
* recursion (expressions can have sub-expressions which can have sub-
expressions)
* the stack data structure
* possibly operator precedence, depending on what your language is
intended to do
Basically you'll want to convert your input -- a sequence of
characters -- into a sequence of tokens (identifiers, numeric
literals, string literals, operators, punctuation, etc.). Then you'll
apply your grammar to that sequence of tokens to derive a parse tree
of expressions (statements, conditional expressions, arithmetic
expressions, function calls, etc.). Then your program will perform
the actions that are described by those expressions (add some numbers,
print something, proceed to the "else" clause rather than the "if"
clause, etc.). Alternatively, you might want to execute actions as
the expressions are derived rather than wait for the whole input to be
parsed.
You *might* want to look at lex and yacc or their GNU counterparts
flex and bison (I say "might" because I've never looked closely at
them myself; I just have a general I idea what they do). Hey, I just
did a Google for "flex bison" and came across this article, which you
might find helpful: <http://www.mactech.com/articles/mactech/Vol.16/16.07/UsingFlexandBison/
>. If you're a Java guy, you might want to read up on JavaCC and
extract additional conceptual background from that.
But really, this has absolutely nothing to do with Xcode.
--Andy
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden