Changes between Version 6 and Version 7 of Commentary/Parser

Show
Ignore:
Timestamp:
08/18/09 12:51:47 (5 years ago)
Author:
benl (IP: 150.203.160.45)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Parser

    v6 v7  
    55The parser has two main goals; to build an AST for the compiler and to give good syntax errors for the compiler user. 
    66 
    7 To meet the second goal, good parser error messages, the use of Parsec.try should be avoided. Parsec.try is problematic because: 
     7== Avoid using the try combinator == 
     8To generate good parser error messages, the use of Parsec.try should be avoided. Parsec.try is problematic because: 
    89 
    910 - The process of starting at the try, parsing forward, failing and then backtracking is slower than parsing with only a single token lookahead. 
     
    1415          x = [ x + 2, y | x <- [ 1, 2, 3, 4 ]] 
    1516      }}} 
    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 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. 
    1718 
    18 Furthermore, 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. 
     19In general, try-less parsing should not make the parser any more difficult to modify or extend.  
    1920 
    2021As an example, a part of the expression parser (src/Source/Parser/Exp.hs) used to look like this