Interesting notation! You can't use literal names in definitions for
other literals. GOLD is reading the definition as containing the
sequence 'days', 'hours'..... or 'milliseconds'.
The easiest way to define the terminal would to have it accept a
series of digits followed by any series of letters. This would also be
repeatable:
time_literal = ('T'|'TIME') '#' ( {Digit}+('.'{Digit}+)? {Letter}+ )+
You would then, after it is parsed, run a check on it being correct.
- Devin
On Thu, Sep 13, 2012 at 3:52 AM, Nikolay Kokorin
<
nikolay...@gmail.com> wrote:
> Hi all,
> I develop parser for the IEC61131-3 Structured Text language. This
> programming language contains the "TIME" literal definition, for example:
> T#10h30m (equal TIME#10.5h) , T#6s300ms, T#1d4h, etc.
>
> How I can to define this litera?
>
> I tried to solve this with using nested literals (as written below), but
> received lexical error on the check grammar stage.
>
> time_literal = ('T'|'TIME')'#'(days|hours|minutes|seconds|milliseconds)
> days = {Digit}+('.'{Digit}+)?'D'
> | {Digit}+'D'(hours)?
> hours = {Digit}+('.'{Digit}+)?'H'
> | {Digit}+'H'(minutes)?
> minutes = {Digit}+('.'{Digit}+)?'M'
> | {Digit}+'M'(seconds)?
> seconds = {Digit}+('.'{Digit}+)?'S'
> | {Digit}+'S'(milliseconds)?
> milliseconds = {Digit}+('.'{Digit}+)?'MS'
>
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "GOLD Parsing System" group.
> To view this discussion on the web visit
>
https://groups.google.com/d/msg/gold-parsing-system/-/BvBfMLXpC8kJ.
> To post to this group, send email to
gold-pars...@googlegroups.com.
> To unsubscribe from this group, send email to
>
gold-parsing-sy...@googlegroups.com.
> For more options, visit this group at
>
http://groups.google.com/group/gold-parsing-system?hl=en.