View Full Version : parsing resource
Whiteknight
10-01-2004, 01:09 PM
I'm looking for a good resource that deals with parsing and lexical analysis, preferably in C (hence the forum choice). I've read through the "Dragon Book" already, and while nice, i thought it was far too theorectical, had too many diagrams and symbols, and not nearly enough code to demonstrate what it was talking about.
I am just looking for some good explanations, and good code examples of parsing and lexical analysis. books or online sources would be awesome.
sicarius
10-04-2004, 07:41 PM
Unfortunately parsing is very theoretical and there isn't much getting around that. I doubt you will find what you are looking for in a book, but I've been wrong before. Go download some source code, or check out flex and bison.
Whiteknight
10-05-2004, 08:03 AM
yeah, i was afraid i was going to hear that kind of message. I've been teaching myself the topic little by little, and have finished a few things, like a standalone C preprocessor, and a mathematical equation parser, but these are basically child's play.
I havent looked yet at felx or bison, although i did look at lex and yacc breifly, and i might be in way over my head. haha, i ahve plenty of time to learn though, so whatever.
sicarius
10-05-2004, 02:39 PM
flex and bison are basically the same (in terms of functionality) as lex and yacc. flex and bison are just newer I think.
Why not just go ahead and write a complete C compiler?
Whiteknight
10-06-2004, 11:58 AM
Originally posted by sicarius
Why not just go ahead and write a complete C compiler?
because in a nutshell, i dont know crap about it. I'm very new to the subject, and havent really done anything even remotely like a compiler in terms of functionality or complexity.
my ASM is par at best, and I dont really want to get involved with machine-language instructions yet.
but, i'll probably be working on one by the end of the year, knowing me.
sicarius
10-06-2004, 05:40 PM
I'm not trying to force you into it because I believe people need to explore things at their own pace, but C is great because it translates so directly to assembly. I wouldn't write a compiler to translate it directly into machine code. Assembly should be the lowest you go.
Whiteknight
10-08-2004, 12:17 PM
My school has a "compiler construction" class that it offers, but i can't take it yet because I dont have enough of the prerequisites. Also, since I'm not a CS major, my chances of getting accepted to it as very low.
also, the university is planning to can the course entirely because the general concensus is that it's a useless subject nowadays. I mostly want to learn all this stuff because many of the concepts and algorithems that are fundamental to the construction of lexical analyzers, parsers, compilers, assemblers, etc.... are very usefull outside of those topics as well.
I'm working mostly on an Equation solver, which will be similar in design and purpose to MATLAB, but will certainly not be as capable.
also, some friends of mine and I are going to start working on a program to perform differentiation and integration, which is going require a very good knowledge of analysis and parsing on my part, because I am the lead coder.
I could start working on a C compiler, although I dont think i am nearly good enough at parsing and whatnot to even get close at this stage, so I am going to D/L some of the GCC source, and start pouring through that to see if i can get some ideas.
the conversion from assembly to machine code is easy enough to do, and It would probably be easier for me to write an assembler right now then a C compiler.
sicarius
10-08-2004, 09:21 PM
Cool. Good luck with all of that.
Although, if your university is going to cancel their compilers course they are making a big mistake. I can't believe that people with Ph.ds in CS would say that compilers are a useless subject.
bioteq
11-08-2004, 02:38 AM
Compilers are a beautiful and yet headache-prone subject.
I, too, have been interested in them in quite some time and although I cannot give you much information that wouldn't be more on the 'theory side' of parsing, I can offer you a good luck, of sorts, into entering the field of study.
Basically, just download the source code to a few compilers and read through them. Some of them, sadly, like GCC, are very..very hard to read and lack the most important thing in code; comments. But if you throw a few hours into looking at it and trying to follow it's flow then you can get some basic ideas into it.
Infact, this is basically what i've been doing with my newest venture into writing a scripting language for personal use. Best of luck. And with that, I welcome my first post of these forums.
vBulletin® v3.7.0, Copyright ©2000-2010, Jelsoft Enterprises Ltd.