I know the title is not clear enough. Here is the details. I need to parse something like below:
Client->iFrame.Initialise() {
res = Server.loadStaticResource()
if (res.status == 404 || res.status == 503) { <1>
throw Error()
}
}
== Initialisation done! == <2>
Client->iFrame.load(data) {
moreStatements()
}
It is a Java-like syntax, except that we support a Divider (shown as == Initialisation done! ==
in the example). Note that:
- both <1> and <2> uses
==
. - It is treated as a Divider only if it appears at the beginning of the line (after spaces removed).
- Any character can be used between the starting
==
and ending==
except for changelines. - There could be more
=
in the Divider component, such as=== 3 equals ===
.
How should I implement that?
What I have tried?
I was looking for a way to use lookahead in the Lexer, but could not find any good examples. I am currently limiting the content between starting ==
and ending ==
to ONE word only.
My implementation is here: