Sign in to follow this  

How is Lisp parsed?

This topic is 4304 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

First of all, I'm not quite certain what you're asking or what you mean by "the output format," but Lisp is very easy to parse. Here's a very basic Lisp grammar, which may help:

atom ::= <identifier> | <number> | <number>/<number> | \" .* \" | #\\\. | #\\f | #\\t
sexp ::= <atom> | \(<sexp> \. <sexp>\) | \(<sexp>*\) | \'<sexp>

It's complicated a bit by the fact that I need to escape several of the characters, but it's not too bad. Note: That is a fully featured Lisp grammar.

Again, I'm not entirely sure what you're asking. Could you please clarify?

Share this post


Link to post
Share on other sites
GameMasterXL:

Are you interested in compiled or interpreted lisp?

A lisp compiler will commonly output to some lower level language (such as C or Java) or to a VM bytecode. A simple lisp interpreter would build up the program as a tree of objects (of the various types that exist in lisp: Cons, Number, etc..) and then "walk" this tree to run the program. There are more advanced ways to make an interpreter, but I don't know how much detail you're interested in.

-Alex

Share this post


Link to post
Share on other sites
Quote:
Original post by Roboguy
First of all, I'm not quite certain what you're asking or what you mean by "the output format," but Lisp is very easy to parse. Here's a very basic Lisp grammar, which may help:

atom ::= <identifier> | <number> | <number>/<number> | \" .* \" | #\\\. | #\\f | #\\t
sexp ::= <atom> | \(<sexp> \. <sexp>\) | \(<sexp>*\) | \'<sexp>

It's complicated a bit by the fact that I need to escape several of the characters, but it's not too bad. Note: That is a fully featured Lisp grammar.

Again, I'm not entirely sure what you're asking. Could you please clarify?


That's not enough to parse lisp. You've left number and identifier undefined.

Share this post


Link to post
Share on other sites
Common Lisp is a lot more fun than that to compile: the tokenizer can be customized via reader macros, and the parser can be customized via regular macros =-)

Share this post


Link to post
Share on other sites
Quote:
Original post by Troll
That's not enough to parse lisp. You've left number and identifier undefined.

Literals/identifiers are usually handled by the tokenizer, not the parser. In most grammars, things like number and identifiers are terminals.

Share this post


Link to post
Share on other sites
Thanx for replys is what it is is halo CE uses lisp for its script language well its own intepretation of it so i am just wondering what it would spit out since inside of the game editor it says compile scripts which compiles it into a .scenario file which is a level file but if i open that file up i can read some of the script but some parts i can't. So is this just output in text format or some type of bytecode? i would like to know detail cypherex thnx :). I hope that helps your answering.

Share this post


Link to post
Share on other sites

This topic is 4304 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

Sign in to follow this