summaryrefslogtreecommitdiff
path: root/ide/config_lexer.mll
diff options
context:
space:
mode:
authorGravatar Stephane Glondu <steph@glondu.net>2012-01-12 16:02:20 +0100
committerGravatar Stephane Glondu <steph@glondu.net>2012-01-12 16:02:20 +0100
commit97fefe1fcca363a1317e066e7f4b99b9c1e9987b (patch)
tree97ec6b7d831cc5fb66328b0c63a11db1cbb2f158 /ide/config_lexer.mll
parent300293c119981054c95182a90c829058530a6b6f (diff)
Imported Upstream version 8.4~betaupstream/8.4_beta
Diffstat (limited to 'ide/config_lexer.mll')
-rw-r--r--ide/config_lexer.mll39
1 files changed, 19 insertions, 20 deletions
diff --git a/ide/config_lexer.mll b/ide/config_lexer.mll
index 3724f2bf..57699c68 100644
--- a/ide/config_lexer.mll
+++ b/ide/config_lexer.mll
@@ -1,19 +1,16 @@
(************************************************************************)
(* v * The Coq Proof Assistant / The Coq Development Team *)
-(* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2011 *)
+(* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2010 *)
(* \VV/ **************************************************************)
(* // * This file is distributed under the terms of the *)
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
-(* $Id: config_lexer.mll 14641 2011-11-06 11:59:10Z herbelin $ *)
-
{
open Lexing
open Format
- open Config_parser
- open Util
+ open Minilib
let string_buffer = Buffer.create 1024
@@ -22,34 +19,36 @@
let space = [' ' '\010' '\013' '\009' '\012']
let char = ['A'-'Z' 'a'-'z' '_' '0'-'9']
let ident = char+
+let ignore = space | ('#' [^ '\n']*)
-rule token = parse
- | space+ { token lexbuf }
- | '#' [^ '\n']* { token lexbuf }
- | ident { IDENT (lexeme lexbuf) }
- | '=' { EQUAL }
- | '"' { Buffer.reset string_buffer;
- Buffer.add_char string_buffer '"';
- string lexbuf;
- let s = Buffer.contents string_buffer in
- STRING (Scanf.sscanf s "%S" (fun s -> s)) }
+rule prefs m = parse
+ |ignore* (ident as id) ignore* '=' { let conf = str_list [] lexbuf in
+ prefs (Stringmap.add id conf m) lexbuf }
| _ { let c = lexeme_start lexbuf in
- eprintf ".coqiderc: invalid character (%d)\n@." c;
- token lexbuf }
- | eof { EOF }
+ eprintf "coqiderc: invalid character (%d)\n@." c;
+ prefs m lexbuf }
+ | eof { m }
+
+and str_list l = parse
+ | ignore* '"' { Buffer.reset string_buffer;
+ Buffer.add_char string_buffer '"';
+ string lexbuf;
+ let s = Buffer.contents string_buffer in
+ str_list ((Scanf.sscanf s "%S" (fun s -> s))::l) lexbuf }
+ |ignore+ { List.rev l}
and string = parse
| '"' { Buffer.add_char string_buffer '"' }
| '\\' '"' | _
{ Buffer.add_string string_buffer (lexeme lexbuf); string lexbuf }
- | eof { eprintf ".coqiderc: unterminated string\n@." }
+ | eof { eprintf "coqiderc: unterminated string\n@." }
{
let load_file f =
let c = open_in f in
let lb = from_channel c in
- let m = Config_parser.prefs token lb in
+ let m = prefs Stringmap.empty lb in
close_in c;
m