![]() |
| ||
| New Parser Generator I have recently created a parser generator named the Lithium Parser Generator (LiPG). I also wrote a pretty readable documentation for it. I was wondering if anyone could give me some feedback - especially if you have experience with other parser generators like Bison/Flex, etc. The Doc:http://www.uweb.ucsb.edu/~frenchenee...mentation.html Thanks |
| ||
| Re: New Parser Generator void getline(char* line) You shouldn't use broken code examples. parse ws This is _extremely_ verbose for something that just parses whitespace. I'm pretty sure that's simpler to do in other parser generators, and more readable. For example, with ANTLR (and I might be buggy here, I haven't seen ANTLR myself except on IRC channels), you would just see something like WS : (' '|'\t'|'\f'|'\n'|'\r')+ { $channel=HIDDEN; };For a parser combinator library like Parsec, it would just be ws = skipMany1 (satisfy isSpace) |
| ||
| Re: New Parser Generator Also, I don't see the reason to have two mechanisms for concatenating parsers: successive choice blocks and wordforms. They do the same thing, so they add needless redundancy. Your 'anychar[]' and 'anyindex' features seem unnecessary, almost silly. To say you want a string of characters that satisfy a given predicate, you already have that feature. |
| ||
| Re: New Parser Generator Quote:
Quote:
I was thinking it might be useful to have syntax like this: parse ws [-> " " || "\t" || "\t" [ return true; ] ] Do you think that would be worth while? In other words, do you think that is acceptable verbosity? |
| ||
| Re: New Parser Generator Quote:
Quote:
Btw, thanks for delving so deep into this - I appreciate the feedback. |
| ||
| Re: New Parser Generator Note that I'm not saying any good things about your project not because they aren't there, but because it just doesn't suit my disposition. Now, if you're going to continue with C++, you should spend some time learning C++. You write C++ like a C programmer. For starters, why are you using malloc? You're writing C++. Using "malloc" or "realloc" in C++ is a huge mistake. You can't just take any old array of type T and call realloc on it. Why not: Because realloc does a raw memory copy, instead of calling the objects' copy constructors. Your 'T' might be a datatype that looks like this: class foo {This class's implementation depends on its location -- if you just copy its raw memory, your class will behave erratically. The same goes for malloc: a = (T*)malloc(n*sizeof(T));is just horrible -- your T's will never get constructed! #define ITER1(x) for(int n1=0; n1<x; n1++) These macros are unsafe and insane. [[Edit: They are unsafe because ITER1(f()) will call f() each time through -- and the user has no way of realizing this. They're insane because they're insane. A slight, but incomplete, improvement, would be to use the following: #define ITER1(x) for(int n1 = 0, e1 = (x); n1 < e1; n1++). There's still the problem that they introduce variables. If the user has a variable named n1 in play, or in my example, e1, they would get unexpected behavior. It would be better to let the user supply his own iterator variable name, and the ending variable name should be something completely unpredictable. But using EACH1 is still insane. ]] Why do you have your own BDArr and BDFifo implementations anyway? There is std::vectorand std::queue for a reason... |
| ||
| Re: New Parser Generator Quote:
|
| ||
| Re: New Parser Generator Quote:
|
| ||
| Re: New Parser Generator Also, it seems to me like 'every' and 'tween' are rather kludgy features. I'll post an example of what I would consider to be a more comfortable C++ parser generator at this level of scope later tonight. |
| |||
| Re: New Parser Generator Quote:
Quote:
Quote:
(make sure if you compile it, don't use optimizations) |
| All times are GMT -4. The time now is 10:25 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC