|
|
|
Re: language with unstructured macros [message #806410 is a reply to message #805532] |
Fri, 24 February 2012 23:43 |
Henrik Lindberg Messages: 2509 Registered: July 2009 |
Senior Member |
|
|
On 2012-23-02 22:46, Vlad Dumitrescu wrote:
> Thanks Henrik,
>
> Quote:
>> Seriously - correctly dealing with macros as a MAJOR pita.
>
>
> I knew this was the case, but hoped somewhat irrationally that there was
> some magic that would ease the pain.
>
Nope, it is really, really awful and difficult to get right, and you
have to override things here, there and everywhere.
> I'm glad that the generated parser has good error recovery and the
> disturbance does not spread through the whole file. If I could ignore
> the related errors in Eclipse, it could be good enough.
>
Nope, no, sorry - if not very hard, it is at least a LOT of work.
I would forget about trying to solve this at the grammar level, it is a
lexing and textual read/write and presentation matter - basically the
lexer needs to evaluate the macros to turn the macros into valid
expressions in the language as this is what the parser needs. At the
same time you need to present things in the editor where the macros are
not expanded.
--- in file "x.header"
#define x = public class
--- in file mystuff
#include x.header
x foo {}
class bar extends foo {}
There is no support for this in Xtext at all. If you really need this, I
suggest talking to the guys at Itemis and pay for help.
Regards
- henrik
|
|
|
Re: language with unstructured macros [message #806961 is a reply to message #806410] |
Sat, 25 February 2012 19:48 |
Vlad Dumitrescu Messages: 431 Registered: July 2009 Location: Gothenburg |
Senior Member |
|
|
Hi!
Quote:> I'm glad that the generated parser has good error recovery and the
> disturbance does not spread through the whole file. If I could ignore
> the related errors in Eclipse, it could be good enough.
>
Nope, no, sorry - if not very hard, it is at least a LOT of work.
I would forget about trying to solve this at the grammar level, it is a
lexing and textual read/write and presentation matter - basically the
lexer needs to evaluate the macros to turn the macros into valid
expressions in the language as this is what the parser needs. At the
same time you need to present things in the editor where the macros are
not expanded.
Fortunately, real-world uses of macros are not very wild and crazy, so there are only a few cases that can happen - mostly that any expression or sequence of expressions can be represented by a macro instance. Unfortunately, this is still enough to make the grammar ambiguous.
I tried to let only the basic structural features of the language remain in place and let the rest be possible to be anything, but it doesn't look too bright. It might work with a backtracking parser, though.
Thanks a gain for the support!
regards,
Vlad
|
|
|
Powered by
FUDForum. Page generated in 0.02593 seconds