changeset 48864 | 3ee314ae1e0a |
parent 48707 | ba531af91148 |
child 48874 | ff9cd47be39b |
48863:881e8a96e617 | 48864:3ee314ae1e0a |
---|---|
37 (** keyword declarations **) |
37 (** keyword declarations **) |
38 |
38 |
39 fun define_keywords ({keywords, ...}: header) = |
39 fun define_keywords ({keywords, ...}: header) = |
40 List.app (Keyword.define o apsnd (Option.map Keyword.spec)) keywords; |
40 List.app (Keyword.define o apsnd (Option.map Keyword.spec)) keywords; |
41 |
41 |
42 fun err_dup name = error ("Inconsistent declaration of outer syntax keyword " ^ quote name); |
42 fun err_dup name = error ("Duplicate declaration of outer syntax keyword " ^ quote name); |
43 |
43 |
44 structure Data = Theory_Data |
44 structure Data = Theory_Data |
45 ( |
45 ( |
46 type T = Keyword.spec option Symtab.table; |
46 type T = Keyword.spec option Symtab.table; |
47 val empty = Symtab.empty; |
47 val empty = Symtab.empty; |
73 val beginN = "begin"; |
73 val beginN = "begin"; |
74 |
74 |
75 val header_lexicon = |
75 val header_lexicon = |
76 Scan.make_lexicon |
76 Scan.make_lexicon |
77 (map Symbol.explode |
77 (map Symbol.explode |
78 ["%", "(", ")", "::", ";", "and", beginN, headerN, importsN, keywordsN, theoryN, usesN]); |
78 ["%", "(", ")", ",", "::", ";", "and", beginN, headerN, importsN, keywordsN, theoryN, usesN]); |
79 |
79 |
80 |
80 |
81 (* header args *) |
81 (* header args *) |
82 |
82 |
83 local |
83 local |
84 |
84 |
85 val file_name = Parse.group (fn () => "file name") Parse.path; |
85 val file_name = Parse.group (fn () => "file name") Parse.path; |
86 val theory_name = Parse.group (fn () => "theory name") Parse.name; |
86 val theory_name = Parse.group (fn () => "theory name") Parse.name; |
87 |
87 |
88 val keyword_kind = Parse.group (fn () => "outer syntax keyword kind") (Parse.name -- Parse.tags); |
88 val opt_files = |
89 Scan.optional (Parse.$$$ "(" |-- Parse.!!! (Parse.list1 Parse.name) --| Parse.$$$ ")") []; |
|
90 val keyword_spec = |
|
91 Parse.group (fn () => "outer syntax keyword specification") |
|
92 (Parse.name -- opt_files -- Parse.tags); |
|
93 |
|
89 val keyword_decl = |
94 val keyword_decl = |
90 Scan.repeat1 Parse.string -- Scan.option (Parse.$$$ "::" |-- Parse.!!! keyword_kind) >> |
95 Scan.repeat1 Parse.string -- Scan.option (Parse.$$$ "::" |-- Parse.!!! keyword_spec) >> |
91 (fn (names, kind) => map (rpair kind) names); |
96 (fn (names, spec) => map (rpair spec) names); |
92 val keyword_decls = Parse.and_list1 keyword_decl >> flat; |
97 val keyword_decls = Parse.and_list1 keyword_decl >> flat; |
93 |
98 |
94 val file = |
99 val file = |
95 Parse.$$$ "(" |-- Parse.!!! (file_name --| Parse.$$$ ")") >> rpair false || |
100 Parse.$$$ "(" |-- Parse.!!! (file_name --| Parse.$$$ ")") >> rpair false || |
96 file_name >> rpair true; |
101 file_name >> rpair true; |