author | Walther Neuper <neuper@ist.tugraz.at> |
Tue, 01 Mar 2011 15:23:59 +0100 | |
branch | decompose-isar |
changeset 41905 | b772eb34c16c |
permissions | -rw-r--r-- |
neuper@41905 | 1 |
theory syntaxe imports Main begin |
neuper@41905 | 2 |
|
neuper@41905 | 3 |
section {* Old parsing *} |
neuper@41905 | 4 |
text {* Old parsing in ISAC used theories *} |
neuper@41905 | 5 |
ML {* |
neuper@41905 | 6 |
val thy = @{theory}; |
neuper@41905 | 7 |
fun parse thy str = Syntax.read_term_global thy str; |
neuper@41905 | 8 |
val env = |
neuper@41905 | 9 |
[(parse thy "equ::bool", parse thy "x + (1::int) = 2"), |
neuper@41905 | 10 |
(parse thy "var::int", parse thy "x::int"), |
neuper@41905 | 11 |
(parse thy "sol::bool", parse thy "(x::int) = 1") |
neuper@41905 | 12 |
]; |
neuper@41905 | 13 |
val precond = parse thy "(0::int) < x" |
neuper@41905 | 14 |
*} |
neuper@41905 | 15 |
text {* However, user input could not be parsed ...*} |
neuper@41905 | 16 |
ML {* parse thy "x = 2 - 1" *} |
neuper@41905 | 17 |
text {* ... because the type 'int' is lost (we have type 'a now). |
neuper@41905 | 18 |
The learner would need to input x::int all the time. *} |
neuper@41905 | 19 |
|
neuper@41905 | 20 |
section {* Contexts *} |
neuper@41905 | 21 |
ML {* |
neuper@41905 | 22 |
val ctxt = ProofContext.init_global thy; |
neuper@41905 | 23 |
|
neuper@41905 | 24 |
(*... prepare ctxt ...*) |
neuper@41905 | 25 |
|
neuper@41905 | 26 |
fun parseNEW ctxt str = Syntax.read_term ctxt str; |
neuper@41905 | 27 |
*} |
neuper@41905 | 28 |
|
neuper@41905 | 29 |
section {* New parsing *} |
neuper@41905 | 30 |
text {* New parsing in ISAC uses contexts, which are rigorously updated |
neuper@41905 | 31 |
by the Lucas-Interpreter. Then ...*} |
neuper@41905 | 32 |
ML {* parse thy "x = 2 - 1" *} |
neuper@41905 | 33 |
text {* ... x gets type 'int' from the context. *} |
neuper@41905 | 34 |
end |