• 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
Name
Last commit
Last update
benchmarks Loading commit data...
compile Loading commit data...
doc Loading commit data...
driver Loading commit data...
misc Loading commit data...
ocaml @ ecc80c0d Loading commit data...
ocamliface Loading commit data...
parser Loading commit data...
query Loading commit data...
runtime Loading commit data...
schema Loading commit data...
tests Loading commit data...
tools Loading commit data...
types Loading commit data...
typing Loading commit data...
web Loading commit data...
win32 Loading commit data...
.gitignore Loading commit data...
.gitmodules Loading commit data...
.ocamlinit Loading commit data...
AUTHORS Loading commit data...
CHANGES Loading commit data...
INSTALL Loading commit data...
INSTALL.RPM Loading commit data...
INSTALL.WIN32 Loading commit data...
INSTALL.mingw Loading commit data...
LICENSE Loading commit data...
META.in Loading commit data...
Makefile Loading commit data...
Makefile.binary Loading commit data...
Makefile.conf.template Loading commit data...
Makefile.distrib Loading commit data...
Makefile.macosx Loading commit data...
Makefile.types Loading commit data...
PLIST.godi Loading commit data...
README Loading commit data...
TODO Loading commit data...
VERSION Loading commit data...
_tags Loading commit data...
boolVarOUnit.mlpack Loading commit data...
cduce-expat.spec Loading commit data...
cduce.spec Loading commit data...
cduce_mktop Loading commit data...
configure Loading commit data...
configure.ml Loading commit data...
depend Loading commit data...
header Loading commit data...
myocamlbuild.ml Loading commit data...
opam_config.sh Loading commit data...
typesOUnit.mlpack Loading commit data...
win-installer.readme Loading commit data...