r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[REBOL Syntax] Discussions about REBOL syntax

Steeve
6-Mar-2012
[396x2]
About short Date syntax .
A valid month is taken from system/locale/months:
== ["January" "February" "March" "April" "May" "June"
    "July" "August" "September" "October" "November" "December"
]

The month must be 3 letters a least, but longer sub-strings are valid 
forms as well:

eg. 1-Jan-2000, 1-Janu-2000, 1-Janua-2000,1-Januar-2000,1-January-2000.


One can do a simple rebol function to pick-up a valid month from 
system/locale/months.

Doing this only with plain formal static parse rules would be painfull 
because it should include all the valid sub-strings.
eg. ["Jan" | "Janu" | "Janua" | ...]

What do you think ?
I try to resume my thought.
Is it valid to run some code in the rules using (...) ?
Ladislav
6-Mar-2012
[398]
Hmm, that is what we wanted to not use...
Andreas
6-Mar-2012
[399x2]
No () please, but you can of course use code to generate the static 
rule in the first place :)
[
    "Jan" | "Janu" | "Janua" | "Januar" | "January" |

    "Feb" | "Febr" | "Febru" | "Februa" | "Februar" | "February" |
    "Mar" | "Marc" | "March" |
    "Apr" | "Apri" | "April" |
    "May" |
    "Jun" | "June" |
    "Jul" | "July" |
    "Aug" | "Augu" | "Augus" | "August" |

    "Sep" | "Sept" | "Septe" | "Septem" | "Septemb" | "Septembe" | "September" 
    |
    "Oct" | "Octo" | "Octob" | "Octobe" | "October" |

    "Nov" | "Nove" | "Novem" | "Novemb" | "Novembe" | "November" |
    "Dec" | "Dece" | "Decem" | "Decemb" | "Decembe" | "December"
]
Steeve
6-Mar-2012
[401]
Even something like that ?


months: {-January-February-March-April-May-June-July-August-September-October-November-December}
check-month: use [sav *month][
	[copy *month [#"-" 3 20 letters] sav: :months to *month :sav]
]

probe parse "1-Marc-2000" [1 2 digits check-month #"-" 1 4 digits]
Andreas
6-Mar-2012
[402x3]
Yes, strictly no code blocks in the rules.
Just use the generated block :)
(Ah, and no "advanced" parse constructs. Trying to stay PEG compatible.)
Ladislav
6-Mar-2012
[405x2]
The order of subwords in the above "exhaustive rule" shall be reversed, 
though.
month-names rule committed
Andreas
6-Mar-2012
[407]
(Ahem, yes of course. Thanks for fixing that, Ladislav.)
Ladislav
8-Mar-2012
[408:last]
However, the example Steeve posted does not contain "code blocks"