Changes between Version 5 and Version 6 of Commentary/Parser

Show
Ignore:
Timestamp:
08/18/09 11:59:53 (5 years ago)
Author:
erikd (IP: 203.206.230.162)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Parser

    v5 v6  
    99 - The process of starting at the try, parsing forward, failing and then backtracking is slower than parsing with only a single token lookahead. 
    1010   
    11  - Using try means that any failure will backtrack to the inner most try which is not really where the parse failed. This means that Parsec will not be able to produce good parser error messages. For instance, with the old version of the parser, parsing: 
     11 - Using try means that any failure will backtrack to the inner most try which is not really where the parse failed. This means that Parsec will not be able to produce good parser error messages. For instance, if the parser uses Parsec.try to parse a faulty list comprehension like this: 
    1212 
    1313      {{{ 
    1414          x = [ x + 2, y | x <- [ 1, 2, 3, 4 ]] 
    1515      }}} 
    16    would result in the list parser getting to the '|' token, failing and backtracking to the '=' token. When all other parser combinators also fail, the parser would flag an error at the '=' token. The try-less parser on the other hand would correctly flag the error at the '|' token. 
    17    
     16   the parser would get to the '|' token, fail and backtrack to the '=' token. When all other parser combinators also fail, the parser would flag an error at the '=' token. The try-less parser on the other hand would correctly flag the error at the '|' token. 
     17 
    1818Furthermore, try-less parsing should not make the parser any more difficult to modify or extend. Quite the contrary, the try-less parser is easier debug and easier to extend once the concepts of try-less parsing are understood. 
    1919