123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166(*********************************************************************************)(* Higlo *)(* *)(* Copyright (C) 2014-2021 Institut National de Recherche en Informatique *)(* et en Automatique. All rights reserved. *)(* *)(* This program is free software; you can redistribute it and/or modify *)(* it under the terms of the GNU Lesser General Public License version *)(* 3 as published by the Free Software Foundation. *)(* *)(* This program is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU Library General Public License for more details. *)(* *)(* You should have received a copy of the GNU Lesser General Public *)(* License along with this program; if not, write to the Free Software *)(* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA *)(* 02111-1307 USA *)(* *)(* Contact: Maxence.Guesdon@inria.fr *)(* *)(* *)(*********************************************************************************)openLangletlexemelb=Sedlexing.(Utf8.lexemelb,lexeme_lengthlb);;letsedlexeme=Sedlexing.Utf8.lexeme;;letdigit=[%sedlex.regexp?'0'..'9'|'_']lethex=[%sedlex.regexp?digit|'A'..'F'|'a'..'f']letinteger=[%sedlex.regexp?Plus(digit)]letdecimal=[%sedlex.regexp?Star('0'..'9'),'.',Plus('0'..'9')]letexponent=[%sedlex.regexp?('e'|'E'),Opt('+'|'-'),Plus('0'..'9')]letdouble=[%sedlex.regexp?(Plus('0'..'9'),'.',Star('0'..'9'),exponent)|('.',Plus('0'..'9'),exponent)|(Plus('0'..'9'),exponent)]letinteger_positive=[%sedlex.regexp?'+',integer]letdecimal_positive=[%sedlex.regexp?'+',decimal]letdouble_positive=[%sedlex.regexp?'+',double]letinteger_negative=[%sedlex.regexp?'-',integer]letdecimal_negative=[%sedlex.regexp?'-',decimal]letdouble_negative=[%sedlex.regexp?'-',double]letbinary=[%sedlex.regexp?"0b",Plus('0'|'1')]letoctal=[%sedlex.regexp?"0o",Plus('0'..'7')]lethexa=[%sedlex.regexp?"0x",Plus(hex)]letnumeric=[%sedlex.regexp?integer_positive|decimal_positive|double_positive|integer_negative|decimal_negative|double_negative|integer|decimal|double|binary|octal|hexa]letboolean=[%sedlex.regexp?"true"|"false"]letechar=[%sedlex.regexp?'t'|'b'|'n'|'r'|'f'|'\\'|'"'|'\'']letescaped_char=[%sedlex.regexp?'\\',echar]letstring=[%sedlex.regexp?'"',Star(Compl(0x22)|escaped_char),'"']letchar=[%sedlex.regexp?"'",(Compl(0x27)|escaped_char),"'"]letspace=[%sedlex.regexp?Plus(' '|'\n'|'\t'|'\r')]letcapchar=[%sedlex.regexp?'A'..'Z']letlowchar=[%sedlex.regexp?'a'..'z']letidchar=[%sedlex.regexp?lowchar|capchar|'_'|digit]letmodname=[%sedlex.regexp?capchar,Star(idchar)]letstart_comment=[%sedlex.regexp?"(*"]letend_comment=[%sedlex.regexp?"*)"](* 28 is left parenthesis, 29 is right parenthesis;
do not eat char and string delimiter, as they
are handled in lexer, or else the the comment char would
eat the string or char start chararacter.
*)letcomment_char=[%sedlex.regexp?(Compl(0x28|0x29|'"'|'\''|'*')|(0x28,Compl('\''|'"'|'*'))|('*',Compl('\''|'"'|0x29)))]letid=[%sedlex.regexp?('_'|lowchar),Star(idchar)]letcap_id=[%sedlex.regexp?capchar,id]letattr_id=[%sedlex.regexp?(id|cap_id),Star('.',Plus(id|cap_id))]letpercent_id=[%sedlex.regexp?'%',attr_id]letdecl_kw=[%sedlex.regexp?"and"|"class"|"constraint"|"exception"|"external"|"let"|"fun"|"function"|"functor"|"in"|"include"|"inherit"|"initializer"|"method"|"module"|"mutable"|"nonrec"|"of"|"open"|"private"|"rec"|"type"|"val"|"virtual"](* split keyword list because of sedlex bug:
https://github.com/ocaml-community/sedlex/issues/97 *)letexpr_kw=[%sedlex.regexp?"asr"|"do"|"else"|"for"|"if"|"while"|"as"|"assert"|"begin"|"do"|"done"|"downto"]letexpr_kw2=[%sedlex.regexp?"else"|"end"|"for"|"if"|"land"|"lazy"|"lor"|"lsl"|"lsr"|"lxor"|"match"|"mod"]letexpr_kw3=[%sedlex.regexp?"new"|"object"|"or"|"ref"|"sig"|"struct"|"then"|"to"|"try"|"when"|"while"|"with"|"#"]lettype_kw=[%sedlex.regexp?"bool"|"int"|"string"|"list"|"array"|"float"|"char"|"unit"]letlwt_kw=[%sedlex.regexp?"lwt"|"raise_lwt"|">>="|">>"|"=<<"|"for_lwt"|"assert_lwt"|"match_lwt"|"while_lwt"]letlabel=[%sedlex.regexp?'~',id]letdirective=[%sedlex.regexp?Opt('\n',Opt('\r')),'#',lowchar,Star(idchar)]letrecmainlexbuf=match%sedlex