PsiBuilder.Marker

Can I get some more hints on this one?
Is there any order I can use those markers? Must they be released in the
same order as being obtained? Must I release every marker or it's enough
to just release an parent marker?

Markaer.done() is clear.
Is Marker.proceed() the same as advanceLexer() and then mark()?
What's the difference between Marker.drop() and Marker.rollbackTo()?

Thanks, Sven.

3 comments
Comment actions Permalink

Is there any order I can use those markers? Must they be released in
the same order as being obtained?

I'd say they must be released in order opposite to when they've been taken.

Must I release every marker or it's enough to just release an parent marker?

You have to release every marker you taken.

There are 3 ways to release a marker.
- done() is clear just as you've said.
- drop() eliminates the marker as if it never been taken
- rollbackTo() eliminates the marker plus rolls back the lexer to the position
where this marker have been taken.

Marker.preceed() (note it's preceed, not proceed) creates a new marker just
before 'this'. Both of them have to be released separately. This method is
useful for right-to-left parsing when you don't know how many markers you
need at certain position until you read more input. Example is binary expression
parsing like abc should be treated as (a(bc)) thus you need two markers
at 'a' position, which fact isn't known until you get to 'c' lexem.

Hope this helps.

-


Maxim Shafirov
http://www.jetbrains.com
"Develop with pleasure!"


0
Comment actions Permalink

Thanks for the detailed answer.
Still one question :)

- rollbackTo() eliminates the marker plus rolls back the lexer to the
position where this marker have been taken.

I suppose this also strips all markers which haven been done() after
this one, right?

Sven.

0
Comment actions Permalink

I suppose this also strips all markers which haven been done() after
this one, right?

Quite right.

-


Maxim Shafirov
http://www.jetbrains.com
"Develop with pleasure!"


0

Please sign in to leave a comment.