1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798(*********************************************************************************)(* OCaml-RDF *)(* *)(* Copyright (C) 2012-2024 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 General Public License for more details. *)(* *)(* You should have received a copy of the GNU 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 *)(* *)(*********************************************************************************)(** *)(* https://www.rfc-editor.org/rfc/rfc5646.html#section-2.1 *)moduleL=Sedlexing.Utf8letdigit=[%sedlex.regexp?'0'..'9']letalpha=[%sedlex.regexp?'a'..'z'|'A'..'Z']letalphanum=[%sedlex.regexp?digit|alpha]letscript=[%sedlex.regexp?alpha,alpha,alpha,alpha]letregion=[%sedlex.regexp?(alpha,alpha)|(digit,digit,digit)]letsingleton=[%sedlex.regexp?digit|0x41..0x57|0x59..0x5A|0x61..0x77|0x79..0x7A]letprivateuse=[%sedlex.regexp?"x",Plus("-",alphanum,alphanum,Opt(alphanum),Opt(alphanum),Opt(alphanum),Opt(alphanum),Opt(alphanum),Opt(alphanum))]letextension=[%sedlex.regexp?singleton,Plus("-",alphanum,alphanum,Opt(alphanum),Opt(alphanum),Opt(alphanum),Opt(alphanum),Opt(alphanum),Opt(alphanum))]letvariant=[%sedlex.regexp?(alphanum,alphanum,alphanum,alphanum,alphanum,Opt(alphanum),Opt(alphanum),Opt(alphanum))|(digit,alphanum,alphanum,alphanum)]letextlang=[%sedlex.regexp?(alpha,alpha,alpha)|(("-",alpha,alpha,alpha),Plus("-",alpha,alpha,alpha))]letlanguage=[%sedlex.regexp?(alpha,alpha,Opt(alpha),Opt("-",extlang))|(alpha,alpha,alpha,alpha),Opt(alpha),Opt(alpha),Opt(alpha),Opt(alpha)]letlangtag=[%sedlex.regexp?language,Opt("-",script),Opt('-',region),Star("-",variant),Star("-",extension),Opt("-",privateuse)]letirregular=[%sedlex.regexp?"en-GB-oed"|"i-ami"|"i-bnn"|"i-default"|"i-enochian"|"i-hak"|"i-klingon"|"i-lux"|"i-mingo"|"i-navajo"|"i-pwn"|"i-tao"|"i-tay"|"i-tsu"|"sgn-BE-FR"|"sgn-BE-NL"|"sgn-CH-DE"]letregular=[%sedlex.regexp?"art-lojban"|"cel-gaulish"|"no-bok"|"no-nyn"|"zh-guoyu"|"zh-hakka"|"zh-min"|"zh-min-nan"|"zh-xiang"]letgrandfathered=[%sedlex.regexp?irregular|regular]letlanguage_tag=[%sedlex.regexp?(langtag|privateuse|grandfathered),eof]letlanguage_taglexbuf=match%sedlexlexbufwith|language_tag->()|_->failwith"Invalid language tag"letis_valid_language_tagstr=letlexbuf=Sedlexing.Utf8.from_stringstrintrylanguage_taglexbuf;truewithFailure_->false