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

Parse learning problem (simple)

 [1/3] from: joesolinsky:ya:hoo at: 29-Nov-2007 22:07


Hello, I would very much like to write a trivial parser that will consume the following format letter: charset [#"a" - #"z" #"A" - #"Z"] digit: charset [#"0" - #"9"] letter-or-digit: union letter digit valid-name: [letter any letter-or-digit] params: [valid-name | valid-name "," params] function-rule: [valid-name "(" params ")" ] and recognize the following input: parse "person(fred)" function-rule parse "buys(fred,shoes)" function-rule I would also dearly like to change function-rule and params to capture and store the "valid-name" values, related to each other. As usual, REBOL syntax is more "powerful" than I can understand. Also, a commentary question: I'm exploring first-order logic. Is REBOL a poor choice over Prolog for this? Thanks for your input. -Joe Solinsky ____________________________________________________________________________________ Be a better pen pal. Text or chat with friends inside Yahoo! Mail. See how. http://overview.mail.yahoo.com/

 [2/3] from: Tom::Conlin::gmail::com at: 29-Nov-2007 22:26


Joe Solinsky wrote:
> Hello, > I would very much like to write a trivial parser that will consume the following format
<<quoted lines omitted: 14>>
> Thanks for your input. > -Joe Solinsky
store: copy [] letter: charset [#"a" - #"z" #"A" - #"Z"] digit: charset [#"0" - #"9"] alphanum: union letter digit valid-name: [letter any alphanum] params: [ copy token valid-name (insert/only tail store token) opt ["," params] ] function-rule: [ copy token valid-name (insert/only tail store token) "(" params ")" ] ;;; use /all whenever you make a block rule parse/all "person(fred)" function-rule parse/all "buys(fred,shoes)" function-rule probe store == ["person" "fred" "buys" "fred" "shoes"]

 [3/3] from: joesolinsky::yahoo::com at: 30-Nov-2007 7:38


Tom, Thank you for your assistance. I am now happily producing all sorts of production rules that work. REBOL is not a language to learn in a vacuum. -Joe Solinsky ----- Original Message ---- From: Tom <Tom.Conlin-gmail.com> To: rebolist-rebol.com Sent: Friday, November 30, 2007 12:26:16 AM Subject: [REBOL] Re: Parse learning problem (simple) store: copy [] letter: charset [#"a" - #"z" #"A" - #"Z"] digit: charset [#"0" - #"9"] alphanum: union letter digit valid-name: [letter any alphanum] params: [ copy token valid-name (insert/only tail store token) opt ["," params] ] function-rule: [ copy token valid-name (insert/only tail store token) "(" params ")" ] ;;; use /all whenever you make a block rule parse/all "person(fred)" function-rule parse/all "buys(fred,shoes)" function-rule probe store == ["person" "fred" "buys" "fred" "shoes"] ____________________________________________________________________________________ Get easy, one-click access to your favorites. Make Yahoo! your homepage. http://www.yahoo.com/r/hs

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted