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

[REBOL] Re: More dialects than you think, validating function input.

From: greggirwin:mindspring at: 13-Sep-2002 12:52

Hi Brett, << As for the expecting bit. I don't think there is a general solution. Having to tell the user "error...expecting money" adds an application requirement making a bigger application. Each "expecting X" becomes an alternative rule to the rule that is attempting a match. So your rules bloat out quite a bit if you want to report on every grammar term. For some apps maybe it is enough to say "Recognised two stock orders. Could not recognise the rest of the instructions." >> I think I didn't say that I thought more than I said. :) What I was *thinking*, but didn't write in my message, was how many parsers provide context information when a syntax error occurs and that PARSE might be able to make available that kind of information so we don't have to do it all ourselves at the individual rule level. F'rinstance:
>> add 1
** Script Error: add expected value2 argument of type: number pair char money date time tuple ** Near: add 1 REBOL has rules about how to parse code based on the spec block (the rule) for a function, no? So, based on the rule(s) that have succeeded, you know what state the parser was in when it hit a rule that failed, and what that rule (or rules) was. I like the way it works today, not popping an error directly to the user, but you have no idea exactly where the parse failed unless, as you point out, you add stuff to all your rules to track exactly what's going on. Maybe that ends up being a viable alternative in some cases, but if PARSE gave us some more clues, it might be useful. Another problem I have is that I start thinking way ahead of myself about what could be . I can see great potential for higher level dialects driving PARSE; generating rules dynamically (including specific constraints) based on data from a database, previous messages in a conversation, etc.; and tools to help visualize and debug dialects. I just about jump out of my seat when I think about some of the possibilities. :) --Gregg