World: r3wp
[REBOL Syntax] Discussions about REBOL syntax
older | first |
Maxim 24-Feb-2012 [359] | date has many variations, its probably the more complex one left |
Steeve 24-Feb-2012 [360] | yep |
Maxim 24-Feb-2012 [361] | actually, path! also has a few quirks, like allowing parens and the use of a get-set-word at the end |
Steeve 24-Feb-2012 [362] | but path! needs all the other dataypes to be finished first |
Maxim 24-Feb-2012 [363x2] | no, afaik, just paren!, word and its own additional format quirks. as the global block definition expacts, so too will parens, and thus the path. |
expacts... expands | |
Steeve 24-Feb-2012 [365] | So, path! is not complex in that regard (values separated by '/') |
Maxim 24-Feb-2012 [366] | yeah, just have to find the values which are valid in a path (not all types are valid, at least in R2) |
Steeve 24-Feb-2012 [367] | Agreed |
Maxim 24-Feb-2012 [368x2] | tag! yes, string! no. for example: >> block: [55 "abc" [test] <tag> [test]] == [55 "abc" [test] <tag> [test2]] >> block/"abc" ** Syntax Error: Invalid path -- block/ ** Near: (line 1) block/"abc" >> block/("abc") == [test] >> block/<tag> == [test2] |
I bet you didn't know tags where usable directly ? not many think about it, but since tags are strings, they make a lot of sense for representing XML tree structures... and indeed, I used them when I had namespaced tags. | |
Steeve 24-Feb-2012 [370] | Sorry, I knew ;-) |
Maxim 24-Feb-2012 [371x2] | hehe. but it may adds another complexity to the < parsing rule maybe some precedende in the rule will be required to make sure the this/<tag> isn't short-circuited by another simpler rule. |
maybe some precedende in the rule == . Maybe some precedende manipulations in the rules | |
Steeve 24-Feb-2012 [373] | Ok, I will go first with time! because date! needs it |
Maxim 24-Feb-2012 [374] | remember that there are two different time formats. |
Steeve 24-Feb-2012 [375] | Say ? |
Maxim 24-Feb-2012 [376x2] | [ ##:##:## opt [decimal]] | ##:## ] |
actually... strike that... I just discovered how twisted the loader is . | |
Steeve 24-Feb-2012 [378] | Oh, there are more weird forms than that ;-) |
Maxim 24-Feb-2012 [379] | I just discovered that this is valid: >> 3:3.4 == 0:03:03.4 a dangerous gotcha since: >> 3:3 == 3:03 |
Steeve 24-Feb-2012 [380x3] | :0 0:+ -1:0 |
uhuh | |
lol >> :111111 == 1851:51 | |
Maxim 24-Feb-2012 [383] | maybe we can note to this effect within the comments, to indicate how the time shifts when two or three number values are in the time. hehe I can see a noob scratching his head ;-) 3:03 == 3:03:00 3.03.4 == 0:03:03.4 |
Steeve 24-Feb-2012 [384] | fast division by 60 |
Maxim 24-Feb-2012 [385x2] | wow this one is vile: 0:+ |
its ironic that the above will load but that a single comma with kill the loader :-) | |
Steeve 24-Feb-2012 [387x2] | I can't use the time! rule inside date!, the allowed forms are different. Youpiiiiiiiiii |
Trolololol :))))) time-syntax: [ [ and [#":" digit] ; :## | sign ; +:, -: | opt sign some digit : +-##: ] 1 2 [ #":" not #"." [ opt #"+" any digit #"." any digit not #":" ; :+##.## | #"-." any digit not #":" ; :-.##: | opt #"+" some digit ; :+##: | #"+" ; :+: | #"-" any #"0" ; :-00:, :-: ] ] termination ] | |
Maxim 24-Feb-2012 [389] | simple enough ;-) |
Steeve 24-Feb-2012 [390x5] | Only if it works |
not tested on R2 though | |
All that complication because 'minus' is allowed where it makes no sense | |
Missed one case already... | |
time-syntax: [ [ and [#":" digit] ; :## | sign ; +:, -: | opt sign some digit : +-##: ] 1 2 [ #":" not #"." [ opt #"+" any digit #"." any digit not #":" ; :+##.## | #"-" any #"0" #"." any digit not #":" ; :-00.##: | opt #"+" some digit ; :+##: | #"+" ; :+: | #"-" any #"0" ; :-00:, :-: ] ] termination ] | |
Ladislav 6-Mar-2012 [395] | Committed, did not check it, though. |
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" |
older | first |