1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798(*********************************************************************************)(* 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]letid=[%sedlex.regexp?('_'|lowchar),Star(idchar)]letobj_field=[%sedlex.regexp?(id|string),Opt(space),":"]letrecmainlexbuf=match%sedlexlexbufwith|'{'|'}'->[Symbol(0,lexemelexbuf)]|'['|']'->[Symbol(0,lexemelexbuf)]|','->[Symbol(0,lexemelexbuf)]|space->[Text(lexemelexbuf)]|numeric->[Numeric(lexemelexbuf)]|boolean->[Constant(lexemelexbuf)]|obj_field->Sedlexing.rollbacklexbuf;obj_fieldlexbuf|id->[Keyword(1,lexemelexbuf)]|string->[String(lexemelexbuf)]|char->[String(lexemelexbuf)]|eof->[]|any->[Text(lexemelexbuf)]|_->failwith"Invalid state"andobj_fieldlexbuf=match%sedlexlexbufwith|id|string->lett=Keyword(1,lexemelexbuf)int::obj_fieldlexbuf|space->lett=Text(lexemelexbuf)int::obj_fieldlexbuf|':'->[Symbol(0,lexemelexbuf)]|_->Sedlexing.rollbacklexbuf;mainlexbuflet()=Lang.register_lang"json"main