1. 21 Feb, 2015 1 commit
  2. 20 Feb, 2015 2 commits
  3. 19 Feb, 2015 2 commits
  4. 18 Feb, 2015 1 commit
    • Kim Nguyễn's avatar
      Implement a safety-check to guarantee that recursive parametric types · 3aab1b01
      Kim Nguyễn authored
      remain regular. Within their recursive definitions, parametric types
      must always be instantiated with their original parameters and all
      types of mutually recursive definitions must have the same parameters.
      
      We use Tarjan's strongly connected components algorithm to group type definitions accordingly.
      3aab1b01
  5. 17 Feb, 2015 2 commits
  6. 16 Feb, 2015 6 commits
    • Kim Nguyễn's avatar
      Remove the a workaround the AST for patterns that was used to · 4f49a2af
      Kim Nguyễn authored
      correctly handle insantiated types in regular expressions.
      4f49a2af
    • Kim Nguyễn's avatar
      Add a warning when the lexer encounters the ambiguous ``[ 'a'a ]'' and · bcf40231
      Kim Nguyễn authored
      suggest to put a space before the second quote.
      
      Move the auxiliary 'warning' function from the typechecker to the
      Cduce_loc module.
      
      Re-indent some comments in ulexer.ml
      bcf40231
    • Kim Nguyễn's avatar
      Correctly flush the toplevel output in case the lexer consumes the · b05e438f
      Kim Nguyễn authored
      "\n" after the ;; token.
      b05e438f
    • Kim Nguyễn's avatar
      Fix the handling of polymorphic variables in the lexer. The solution · 36b83c45
      Kim Nguyễn authored
      to use two lexers (depending on whether we are between square brackets
      or not) is too brittle (it crudely tries to parse
       ``( [whitespace] 'a  [whitespace] )'' as a variable, to force the user
      to write the variable beetween parenthesis. However this does not scale
      to types with two arguments (says [ t ('a, 'b) ]).
      
      We use a simpler heuristic (with look ahead)
      
      (1) try to see if the regular expression
      
      ' (anything but ', \n)* '(anything but the first letter of an identifier)
      
      can be found. If so, we put back the lexeme in the buffer and parse it as as
      a string.
      
      (2) if (1) failed, try to parse it as a variable
      
      (3) if (3) failed, try to parse it again as a string. We are
      guaranteed to fail here but it means we have a malformed string, so we
      parse as a string to get a proper error message.
      
      The only thing this does not cover are cases like
      type t = [ 'abcd'Int ]
      which was tokenized before as [, 'abcd', Int, ]
      and is now tokenized as [, 'abcd, 'Int, ]
      It does not seem to be a problem in practice though (since in the code
      I have seen thus far, people were at least putting a space).
      it is easy to emmit a warning in this case, suggesting the user to add
      a whitespace to get the old behaviour back.
      36b83c45
    • Kim Nguyễn's avatar
    • Kim Nguyễn's avatar
      Implement the syntax ``t (t1, …, tn)'' for type instantiation, without · 07bc7bc1
      Kim Nguyễn authored
      requiring an abscence of whitespace between ``t'' and ``(''.  Outside
      of regular expression contexts, ``t (t1, …, tn)'' is parsed with a
      higher precedence than & and \, to allow one to write
      ``t (Int) & Bool'' without extra parentheses (i.e.
      ``(t (Int)) & Bool'').  Inside a regular expression, type
      instantiation and sequencing become ambiguous, and there is no way to
      distinguish syntactically: ``[ Int (Int, Int) ]'' from
      ``[ t (Int, Int) ]''. The former should resolve to a sequence while
      the latter only makes sense as an instantiation (if ``t'' is a
      parametric type). Both are treated as element sequencing and
      disambiguated during identifier resolution (more precisely during the
      "derecurse" phase, before typechecking).
      
      Note that due to the lower precedence of sequencing w.r.t to other
      regular expression constructs, a type ``[ t (Int)* ]'' will be parsed
      correctly, but yield an error message saying that t is not fully
      intantiated. One has to write ``[ (t (Int))* ]'' which is similar to
      function applications for expressions.
      
      Finally, we also re-order sequencing after typing to always group a
      potential type instantiation with its argument, i.e. we transform
      sequences such as
      ``[ t1 t2 t3 ... tn ]'' (which are parsed as
      ``[ (((t1 t2) t3) ... tn) ]'' because sequence concatenation is
      left-associative) into ``[ ... (ti tj) ... ]'' if ``ti'' is an
      identifier and ``tj'' is of the form ``(s1,...,sk)''. This is sound
      because concatenation of regular expression is associative (and the
      original sequence would fail, anyway).
      07bc7bc1
  7. 15 Feb, 2015 2 commits
  8. 13 Feb, 2015 2 commits
  9. 10 Feb, 2015 3 commits
  10. 19 Dec, 2014 2 commits
  11. 18 Dec, 2014 1 commit
  12. 16 Dec, 2014 4 commits
  13. 14 Dec, 2014 2 commits
  14. 06 Dec, 2014 3 commits
  15. 04 Dec, 2014 1 commit
  16. 01 Dec, 2014 6 commits
    • Kim Nguyễn's avatar
      Recursively check in the global normalisation hash table whether the · 86748961
      Kim Nguyễn authored
      type has already been normalized. Without this patch, in the following usage:
      
      norm(T1, delta)
      norm(<a>[ T1 ], delta)
      
      the fact that T1 has already been normalized against some delta is not taken into
      account while normalizin <a>[T1].
      86748961
    • Kim Nguyễn's avatar
      Improve the complexity of constraint normalisation by using a hash · 7932c071
      Kim Nguyễn authored
      table instead of a 'recursion set' like in the paper.  The hash table
      is tricky:
      
       - its keys should be both the type we are normalizing and
      delta
      
       - we should store a flag together with the constraint set, indicating
      whether the computation of the normalization for the corresponding
      type has finished. If it has, we can use the associated constraint set
      instead of CS.sat and stop recursion. If it has not, we can return
      CS.sat (like the previous base case).
      
      We also update the test case files to check that everything is in order:
      
      - part2.cd has been rewritten to make use of the new syntax and remove
        the red-black trees examples that are now in a separate file
      
      - red-black.cd is a fully typechecking file
      - rb-fail.cd has the type definition and the wrong balance function.
      7932c071
    • Kim Nguyễn's avatar
      Fix a bug in toplevel definition of types: · 42dda81a
      Kim Nguyễn authored
      when a type such as
      
      type t('a) = (Int,'a)
      
      is introduced, the variables occuring in the definitions are replaced by fresh occurences.
      The variables in the left-hand-side were note renamed accordingly, yielding a type definition:
      
      type t('a_0) = (Int, 'a_1)
      
      when performing type substitutions, none of the occurences of 'a_1 were replaced.
      42dda81a
    • Kim Nguyễn's avatar
      Simplify (and fix) the code adding variables of a function interface to delta... · 01e9ada9
      Kim Nguyễn authored
      Simplify (and fix) the code adding variables of a function interface to delta during the typing of its body.
      01e9ada9
    • Kim Nguyễn's avatar
      Remove unused exception handling code. · d7b41a1a
      Kim Nguyễn authored
      d7b41a1a
    • Kim Nguyễn's avatar
      Delay the check that detects types variables occurring in patterns until... · 2b0f24c6
      Kim Nguyễn authored
      Delay the check that detects types variables occurring in patterns until type-checking time (this allows us to have access to delta and thus know the monomorphic variables, which are allowed)
      2b0f24c6