Difference between revisions of "Talk:Syntax checking/Parser"
(→find more than one error) |
(→find more than one error) |
||
Line 44: | Line 44: | ||
--[[User:Paulb|Paulb]] 17:59, 18 May 2006 (CEST) | --[[User:Paulb|Paulb]] 17:59, 18 May 2006 (CEST) | ||
+ | |||
+ | |||
+ | Thanks a lot for the code, Paul! | ||
+ | |||
+ | I quickly looked through it and I'll summarize how (I think) it works: eiffel.y is extended is modified like described on the page Manu mentioned (according to Paul it contains bugs because he didn't finish it, and it isn't up to date because eiffel.y was extended to support new language features), so that it reports multiple errors (and stores them in SHARED_ERROR_HANDLER.error_list). It's about a thousand lines longer than the version in the repository. Additionally, there are new ERROR classes that describe the found syntax errors and some helper classes. Paul also mentioned that he made changes to EIFFEL_PARSER_SKELETON, but he couldn't find them. | ||
+ | |||
+ | [[User:Maser|maser]] 20:15, 18 May 2006 (CEST) | ||
== Interface to visualization group == | == Interface to visualization group == |
Revision as of 09:15, 18 May 2006
find more than one error
As far as I've seen, the Parser throws an ERROR as soon as it doesn't like something in the source, which aborts parsing. The found error is in the SHARED_ERROR_HANDLER's error_list (I've never seen more than one error in there, why is it a list anyway?). Has anybody found a way to tell the parser to parse the whole file?
maser 14:55, 17 May 2006 (CEST)
Hmmm... I don't know how to get all the errors with one call. But you haven't to parse the whole file, so you can parse piecewise and if an error occurs, you have to parse after the string that occurs the error. This is a way to get all errors, it's complicated, but it should work!?
Chrigu 17:19, 17 May 2006 (CEST)
Actually read http://www.gobosoft.com/eiffel/gobo/geyacc/error.html for more info on how modifying `eiffel.y' to recover from error and therefore detect more than one error at a time.
--manus 18:10, 17 May 2006 (CEST)
Chrigu: How exactly do you parse piecewise? Though it wouldn't solve the problem because there can be several errors in one piece.
Manu: Thanks for the hint! Looks very promising!
maser 22:55, 17 May 2006 (CEST)
Maser: Couldn't we read several strings of the file and use parse_with_string instead of parse? I'm not sure...
Chrigu 15:52, 18 May 2006 (CEST)
Chrigu: A normal EIFFEL_PARSER accepts just classes, but you can use set_expression_parser (or some other `Parser type setting' feature) to create a parser that parses Eiffel expressions (I knew I had seen something like that before, but couldn't find it yesterday). But changing the eiffel.y file seems like a better solution. Maybe we should use expression and/or feature parsers while checking if a previously found error has been corrected by the user (I assume parsing just one expression is pretty fast).
I've looked through the documentation of gayacc and I think it shouldn't be too difficult to change eiffel.y to our needs, the file's size will probably bethe biggest problem.
maser 16:31, 18 May 2006 (CEST)
Everyone, I've sent Martin something that I worked on a couple a months ago. It's be no means finished or polished. It got put on the back burner because I need to work on other parts of EiffelEnvision. I also do not think it is the most recent version but I will need to check at home for the latest bits.
Basically I sent him what I started implementing for a recoverable parser in the new EiffelEnvision editor. It supported recovering from errors (more complex cannot be support with ease because it's hard to find a recoverable token - Eiffel does not have mandatory end-of-statement tokens like C/C++/C#), precise error/warning reporting (a real message stating excatly what is wrong) and absolute error positions (if you notice EiffelStudio does not always give the exact error location.)
One thing that I started doing, which you guys are going to need to address too, is error/warning spans. It would be nice if the error reporting indicated the start and end coordinates (x1, y1 - x2, y2) of the error, without draining performance.
The parser is common to EiffelStudio/Compiler, EiffelEnvision and a number of internal tools, which is something you need to be aware of. That means do not add any references to anything related to the compiler or EiffelStudio. The parser itself is a stand-alone cluster.
Creating a recoverable parser is hard and placement of those error token is a black art (that's what O'Reilly say and I agree)! Good luck :)
--Paulb 17:59, 18 May 2006 (CEST)
Thanks a lot for the code, Paul!
I quickly looked through it and I'll summarize how (I think) it works: eiffel.y is extended is modified like described on the page Manu mentioned (according to Paul it contains bugs because he didn't finish it, and it isn't up to date because eiffel.y was extended to support new language features), so that it reports multiple errors (and stores them in SHARED_ERROR_HANDLER.error_list). It's about a thousand lines longer than the version in the repository. Additionally, there are new ERROR classes that describe the found syntax errors and some helper classes. Paul also mentioned that he made changes to EIFFEL_PARSER_SKELETON, but he couldn't find them.
maser 20:15, 18 May 2006 (CEST)
Interface to visualization group
As the parser produces ERROR objects and they contain information about position and description of the error and stores them in SHARED_ERROR_HANDLER.error_list, I suggest we use this as interface to exchange the data between the parser and visualisation groups.
maser 16:43, 18 May 2006 (CEST)