[Haskell-cafe] Lazy Parsing (ANN: vcd-0.1.4)

S. Doaitse Swierstra doaitse at swierstra.net
Wed Apr 28 04:07:13 EDT 2010

On 27 apr 2010, at 22:12, Jason Dusek wrote:

>  So UU parsers can construct input?

The perform an editing action on the input so it becomes a sentence of the language recognised. 

> The presence of an
>  empty list in the 2nd slot of the tuple is the only
>  indicator of errors?

The parser wants to see a natural number, whch is a non-empty list of digits. 
So it inserts a single digit, which is any character from the range '0'-'9'. Since no default value is given here, it takes the first one from the range: '0'. Furthermore you get a list of errors, which tell you which correcting steps were taken. There is a special combinator with which you can ask for the errors produced since the last time you asked, and which you can use to control further parsing.

>  For parsing datatypes without a sensible default value,
>  what happens?

If you do nothing you get a less sensible default value; 
you may however provide (lower costs) extra alternatives which will be taken by the correcting process. There is a cost model which can be used to control the correction process. Tokens have a specific insertion cost and a specific deletion cost with which you can play. Usually this is not necessary. The typical process is that at first you do not pay attention to the correction process, and once you see things you really do not want, you provide an extra alternative, or rule out some alternatives by increasuig costs. 

In the UHC token like "if" have a high cost, since we think there is very little chance that people will forget to write them. A ')' can have a lower insertion and deletion cost, since people are more likely to have too many or not enough of them.


> --
> Jason Dusek

More information about the Haskell-Cafe mailing list