user997112
user997112

Reputation: 30605

Haskell, compiler, enforcing the token order?

Could someone give me a small example how you can enforce the order of a language, using Haskell to write a basic compiler?

So for example, if I wanted to write a programming language in which "table bed lamp" was a valid string, but "bed lamp table" wasn't, how would I go about doing this?

If someone could point me in the right direction I think I could then extrapolate and understand this a lot more.

Thanks

Upvotes: 0

Views: 138

Answers (2)

Dominic Mulligan
Dominic Mulligan

Reputation: 466

You seem to have been asking a lot of very basic questions about compilers over the last few days. Is it not better for you to pick up a textbook on compilers and get some grounding, first, before trying to proceed? Appel's book "Modern compiler construction in ML" would be a good start, if you're trying to use Haskell as the language you write the compiler in.

Upvotes: 2

Simon Bergot
Simon Bergot

Reputation: 10582

you should check ressources about parsers. This is the part of a program which is responsible for analysing text, and building data from it. wikipedia entry:

http://en.wikipedia.org/wiki/Parsing

In haskell, Parsec has a reputation of being a powerful library for writing a parser (I have never used it.)

http://www.haskell.org/haskellwiki/Parsec

Upvotes: 3

Related Questions