Better examples needed

May 15, 2009 at 6:59 PM

First of all, thank you for the software. I installed it and it works.

However the complete lack of documentation is not good.

Currently I do not understand how to handle compilation errors. The method described in the CodeProject article

does not work (is it for the previous version ?)

The next thing that looked strange is that the compiler succesfully handled the expression (I made a simple LISP-like test grammar)

( a ( b c d )))  - is it normal and how can I handle such cases ?

Also it is unclear to me how to control the process of parsing. For example, I'd like to stop parse process when it

finds undeclared identifier. So I think there should be a way to intercept the rule and do some checks. How ?

The last thing that remains unclear: should MakePlusRule ALWAYS looks like

someNT.rule = MakePlusRule(someNT ...

?

Coordinator
May 15, 2009 at 10:30 PM

Hi

Answering your questions

However the complete lack of documentation is not good.

Agreed, it sucks

Currently I do not understand how to handle compilation errors. The method described in the CodeProject article

does not work (is it for the previous version ?)

Handle compilation errors? what do you mean? we just show them to user. CodeProject article is quite outdated, sorry

The next thing that looked strange is that the compiler succesfully handled the expression (I made a simple LISP-like test grammar)

( a ( b c d )))  - is it normal and how can I handle such cases ?

Just checked the expression with Scheme sample grammar - parser did correctly report the error - unmatched ending closing ")" (checked in latest source code, not alpha zip from download page).

What "unsuccessful" behavior you expect? maybe something is wrong with your grammar?

Also it is unclear to me how to control the process of parsing. For example, I'd like to stop parse process when it

finds undeclared identifier. So I think there should be a way to intercept the rule and do some checks. How ?

I don't think you can identify undeclared identifier during parsing. You should first parse, and then work with the parse tree and analyze code, and detect undeclared stuff. Even with strongly typed languages like c# i don't think it's possible to detect undeclared during parsing - the identifier might be in the outer scope. It is not syntax, it is semantic error. In general, the best practice is to continue parsing as long as you can (recovering the parser when you find syntax error), and then report errors, all that parser finds.

The last thing that remains unclear: should MakePlusRule ALWAYS looks like

someNT.rule = MakePlusRule(someNT ...

?

Don't understand... why not.. ah, in current implementation you can skip assignment part and simply call MakePlusRule as a proc:

MakePlusRule(someNt, delim, elem);

 Inside the method the someNt.Rule property is already assigned. I recommend to use this the extended version with assignment to make it look just like other BNF rules in grammar, which assign Rule properties