# How is Lisp parsed?

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

## Recommended Posts

How is lisp parsed? i am trying to figure out what the standard compilation of lisp is like what the output format is that it spits out.

##### Share on other sites
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 | #\\tsexp ::= <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 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 on other sites
Quote:
 Original post by RoboguyFirst 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 ::= | | / | \" .* \" | #\\\. | #\\f | #\\tsexp ::= | $$\.$$ | $$*$$ | \'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 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 on other sites
Quote:
 Original post by TrollThat'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 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.

• 11
• 20
• 12
• 10
• 38
• ### Forum Statistics

• Total Topics
631400
• Total Posts
2999862
×