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

[REBOL] Parse to Object Mapping question.

From: steve:shireman:semaxwireless at: 2-Jul-2001 16:58

I expect there might be a simple document to explain this, so here is my question: I want to parse a message, and stuff it into an object if the parsing is valid. Ideally, the structure of the object could be used to create the parsing rule. Here is a simple example, soas not to give away my project: Message-in-ASCII: "RECTANGLE 5.0 CM by 8.0 CM" Geometric-shape: make object![ shape-type: " " size-x: 1.0 size-y: 1.0 units: "inches" ] a manually created parse rule might be-- shape-type: [some char] size: [some digits "." some digits] units ["cm" | "in"] parse-shape-rule [ shape-type spacer size units "by" size units ] so that: parse Message-in-ASCII parse-shape-rule ;should give true if no mistakes instead of the above, it would be nice to have something like: parse message-in-ASCII [ fit Geometric-shape ] ;so object provides parsing rules automatically I hope this is clear enough. Is there already a parse mechanism to fill in an object like this? Thanks, Steve Shireman