12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758(**************************************************************************)(* *)(* All rights reserved.This file is distributed under the terms of the *)(* GNU Lesser General Public License version 2.1 with linking *)(* exception. *)(* *)(* TypeRex 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 *)(* Lesser GNU General Public License for more details. *)(* *)(**************************************************************************)exceptionSyntax_not_foundofstringtypet={keywords:(string*Approx_tokens.token)list;lexer:(Lexing.lexbuf->Approx_tokens.token)option}letextensions=Hashtbl.create17letregistername?(keywords=[])?lexer()=Hashtbl.addextensionsname{keywords;lexer}letavailable()=Hashtbl.fold(funname_acc->name::acc)extensions[]letfind(name:string)=tryHashtbl.findextensionsnamewithNot_found->raise(Syntax_not_foundname)(* predefined extensions *)openApprox_tokenslet_=register"lwt"~keywords:["for_lwt",FOR;"lwt",LET;"match_lwt",MATCH;"try_lwt",TRY;"while_lwt",WHILE;"finally",WITH;(* -- no equivalence for this one, this is a hack ! *)]();register"mll"~keywords:["rule",LET;"parse",FUNCTION;]();register"stream"~keywords:["parser",FUNCTION;]();register"cstruct"~keywords:["cstruct",TYPE;]();register"bitstring"~keywords:["bitmatch",MATCH;]();