| @@ -196,11 +196,14 @@ termination by (relation "measure (\<lambda>(fuel,names,tokens,pos). fuel)") aut |
| 196 | 196 | declare diagnose.simps [simp del] |
| 197 | 197 | |
| 198 | 198 | definition source_error :: "string \<Rightarrow> string" where |
| 199 | | - "source_error s = (case diagnose 128 [] (lex s [] []) 0 of |
| 199 | + "source_error s = (if \<not> list_all (\<lambda>c. nat_of_char c < 128) s then ''source must contain ASCII'' @ newline else |
| 200 | + case diagnose 128 [] (lex s [] []) 0 of |
| 200 | 201 | Failed (Unexpected pos) \<Rightarrow> ''syntax error at token '' @ decimal pos @ newline |
| 201 | | - | Failed (Exhausted pos) \<Rightarrow> ''invalid source or resource limit'' @ newline |
| 202 | + | Failed (Exhausted pos) \<Rightarrow> ''parse depth limit exceeded at token '' @ decimal pos @ newline |
| 202 | 203 | | Parsed (e,rest,pos) \<Rightarrow> if rest \<noteq> [] then ''syntax error at token '' @ decimal pos @ newline |
| 203 | | - else ''invalid source or resource limit'' @ newline)" |
| 204 | + else if nodes e > 4096 then ''program exceeds 4096 nodes'' @ newline |
| 205 | + else if demand (optimise e) > 512 then ''evaluation stack exceeds 512 words'' @ newline |
| 206 | + else ''native validation failed'' @ newline)" |
| 204 | 207 | |
| 205 | 208 | definition artifact :: "string \<Rightarrow> (bool \<times> string) \<times> string" where |
| 206 | 209 | "artifact s = (case prepare s of None \<Rightarrow> ((False,[]), source_error s) |