Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Parsing question

From: lmecir:mbox:vol:cz at: 14-Apr-2003 13:41

Hi Serge,
> I have a parsing question. I am trying to parse a string of PGN format. > it is the formalize way to notee a chess game, for those who don't know. > I want to explicitly say that the space or the newline can end some > sub-pattern. But i have an error message if i use the commented line > below... > > Any idea ? Is there a smarter way of doing this ? > > digit: charset [#"0" - #"9"] > spacer: #" " > ;--- spacer: [#" " | #"^/"] <-- does not work
you can use: spacer: charset [#" " #"^/"] nonspacer: complement spacer
> round_number: [copy x some digit #"." (print join "tour=" x)] > round_played: [copy y to spacer (print join "played=" y)] > round_comment: [#"{" copy comm to #"}" (print comm) to spacer]
instead of to spacer you can then use any nonspacer also see the TO-RULE function, which is defined in http://www.fm.vslib.cz/~ladislav/rebol/parseen.r and the include.r and build.r files.
> round: [round_number round_played round_played opt round_comment] > game: [some round] > rules: [game to end] > > parse "1.d3 d5 2.Nf3 Nf6 3.Bd2 c5 4.g3 Nc6 {a comment} 5.Na3 e6 6.b3 > Be7" rules > > Thank you ! > > -- > Serge Gilette > ------------------------- > 04 92 28 32 50
Regards -Ladislav