Skip to content

ir: Add Ir.parse_spans for Isar command splitting#203

Closed
ike-mulder-aws wants to merge 1 commit intoawslabs:mainfrom
ike-mulder-aws:ir-parse-spans
Closed

ir: Add Ir.parse_spans for Isar command splitting#203
ike-mulder-aws wants to merge 1 commit intoawslabs:mainfrom
ike-mulder-aws:ir-parse-spans

Conversation

@ike-mulder-aws
Copy link
Copy Markdown
Contributor

Expose Isabelle's Outer_Syntax.parse_text via a new Ir.parse_spans command that takes a REPL id and text, outputting 1-based character offsets of each Isar command span. This can be useful for clients of I/R to do fine-grained stepping.

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Expose Isabelle's Outer_Syntax.parse_text via a new Ir.parse_spans
command that takes a REPL id and text, outputting 1-based character
offsets of each Isar command span.

Signed-off-by: Ike Mulder <ikemul@amazon.com>
Comment thread ir/ir.ML
Comment on lines +593 to +600
fun parse_spans id text =
let val thy = Toplevel.theory_of (last_state (the_repl id))
val transitions = Outer_Syntax.parse_text thy (fn () => thy) Position.start text
in List.app (fn tr =>
case Position.offset_of (Toplevel.pos_of tr) of
SOME off => out (string_of_int off)
| NONE => ()) transitions
end;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to expose this low-level functionality, or rather an Ir.explode or similar which 'refines' a REPL by splitting each of its steps into individual commands (either destructively, or creating a new REPL).

@ike-mulder-aws
Copy link
Copy Markdown
Contributor Author

Closing this as this functionality can be achieved without changing the I/R API. Namely, one can Ir.step in a theory an ML_val block which calls the required Outer_Syntax.parse_text on the current theory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants