Re: [Google Groups] using of literals ussue

43 views
Skip to first unread message

Devin Cook

unread,
Sep 16, 2012, 12:49:30 AM9/16/12
to gold-pars...@googlegroups.com
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.

Arsène von Wyss

unread,
Sep 16, 2012, 8:40:11 AM9/16/12
to gold-pars...@googlegroups.com
The following should do what you want:

time_literal = ('T'|'TIME')'#'({Digit}+('.'{Digit}+)?'D'|(({Digit}+'D')?({Digit}+('.'{Digit}+)?'H'|(({Digit}+'H')?({Digit}+('.'{Digit}+)?'M'|(({Digit}+'M')?({Digit}+('.'{Digit}+)?'S'|(({Digit}+'S')?({Digit}+('.'{Digit}+)?'MS')))))))))

;)

Cheers, Arsène

Nikolay Kokorin

unread,
Sep 17, 2012, 12:39:16 AM9/17/12
to gold-pars...@googlegroups.com
Cool ! ))) This is what I wanted... almost. According to the ST language definition, for example, following string is not correct T#1d1m, but T#1d1h1m - is correct.
But it is in principle not critical ;)
Thanks

воскресенье, 16 сентября 2012 г., 16:40:12 UTC+4 пользователь Arsène von Wyss написал:
Reply all
Reply to author
Forward
0 new messages