Hi,
I have figured this out... finally.
This is for anyone out there that may also need this.
Hugo Ferreira wrote:
> Hello,
>
> I have the following rule:
>
> Pcaml.expr: LEVEL "expr1" [
> [
> |"|" ; t = STRING ; "|" -> expand_full_term loc t true
>
Instead of the above simply do:
GLOBAL: Pcaml.expr ;
Pcaml.expr: LEVEL "expr1" [
[
|"|" ; e = log_expr ; "|" -> e
....
];
log_expr: [
[ t = STRING -> expand_full_term loc t true ]
];
> that allows me to process stuff like:
>
> let fxy = | "f(X,Y)." | in
>
> However when I parse "f(X,Y).", an error may also occur. I would like to
> indicate where within this string an error occurs. Unfortunately I have
> the following problem:
>
> let fxy = | "f(X,Y,)." | in
> ^ ^
> 1 2
>
In the above case expand_full_term will have its loc set to (2).
> camlp4 only keeps the location of (1). It then takes the string from (2)
> and gives me that for processing, however the loc is *not* updated to
> (2). I can therefore not use the parsing error position within the
> string as an offset.
>
We can now use the error offset within the string "f(X,Y,)." to offset
the "loc" variable.
> It also seems that the same happens for the LIST0/1 constructs. How can
> I figure out how many white spaces exist between (1) and (2)? If this is
> not possible is there any other way around this?
>
Same is done here as is the case above.
HTHs anyone else with the same issue.
Hugo F.
>
> TIA,
> Hugo Ferreira.
>
>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"ocaml-developer" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/ocaml-developer?hl=en
For other OCaml forums, see http://caml.inria.fr/resources/forums.en.html
-~----------~----~----~----~------~----~------~--~---