(************************************************************************) (* * The Rocq Prover / The Rocq Development Team *) (* v * Copyright INRIA, CNRS and contributors *) (* <O___,, * (see version control and CREDITS file for authors & dates) *) (* \VV/ **************************************************************) (* // * This file is distributed under the terms of the *) (* * GNU Lesser General Public License Version 2.1 *) (* * (see LICENSE file for the text of the license) *) (************************************************************************)
{
open Filename open Lexing
type qualid = stringlist
type load = Logical ofstring | Physical ofstring
type coq_token =
| Require of qualid option * qualid list
| Declare ofstringlist
| Load of load
| External of qualid * string
exception Fin_fichier
exception Syntax_error of int*int
let unquote_string s = String.sub s 1 (String.length s - 2)
let unquote_vfile_string s = let f = unquote_string s in if check_suffix f ".v"then chop_suffix f ".v"else f
let backtrack lexbuf = lexbuf.lex_curr_pos <- lexbuf.lex_start_pos;
lexbuf.lex_curr_p <- lexbuf.lex_start_p
let syntax_error lexbuf = raise (Syntax_error (Lexing.lexeme_start lexbuf, Lexing.lexeme_end lexbuf))
let check_valid lexbuf s = match Unicode.ident_refutation s with
| None -> s
| Some _ -> syntax_error lexbuf
let get_ident lexbuf = let s = Lexing.lexeme lexbuf in check_valid lexbuf s
let get_field_name lexbuf = let s = Lexing.lexeme lexbuf in
check_valid lexbuf (String.sub s 1 (String.length s - 1))
}
let space = [' ''\t''\n''\r'] let lowercase = ['a'-'z'] let uppercase = ['A'-'Z'] let identchar = ['A'-'Z''a'-'z''_''\'' '0'-'9'] let caml_up_ident = uppercase identchar* let caml_low_ident = lowercase identchar*
(* This is an overapproximation, we check correctness afterwards *) let coq_ident = ['A'-'Z''a'-'z''_''\128'-'\255'] ['A'-'Z''a'-'z''_''\'' '0'-'9' '\128'-'\255']* let coq_field = '.' coq_ident let coq_qual_id_rex = coq_ident coq_field+
and extra_dep_rule from = parse
| "(*"
{ comment lexbuf; extra_dep_rule from lexbuf }
| space+
{ extra_dep_rule from lexbuf }
| eof
{ syntax_error lexbuf }
| '"' ([^ '"']+ as f) '"'(*'"'*)
{ skip_to_dot lexbuf;
External (from,f) }
and require_modifiers from = parse
| "(*"
{ comment lexbuf; require_modifiers from lexbuf }
| "Import" space*
{ require_file from lexbuf }
| "Export" space*
{ require_file from lexbuf }
| space+
{ require_modifiers from lexbuf }
| eof
{ syntax_error lexbuf }
| _
{ backtrack lexbuf ; require_file from lexbuf }
and consume_require_or_extradeps only_extra_dep from = parse
| "(*"
{ comment lexbuf; consume_require_or_extradeps only_extra_dep from lexbuf }
| space+
{ consume_require_or_extradeps only_extra_dep from lexbuf }
| "Require" space+
{ if only_extra_dep then syntax_error lexbuf; require_modifiers from lexbuf }
| "Extra" space+ "Dependency" space+
{ match from with
| None -> syntax_error lexbuf (* Extra Dependency requires From *)
| Some from -> extra_dep_rule from lexbuf }
| _
{ syntax_error lexbuf }
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.