Analyzing Control Structures

General APL language issues

Analyzing Control Structures

Postby paulmansour on Mon Oct 26, 2020 1:09 pm

I have a domain specific language. Users write scripts in it. I have a tracer that allows them to step through the scripts line by line. The scripting language allows most of the Dyalog control structures :For, :While, :If, etc.

Being lazy, I like to get the interpreter to do most of the work for me. If a take a script in my DSL and fix it as a Dyalog function, all of the control structures are case normalized, indented, lined, up, etc. I can then do some relatively easy analysis of the ⎕NR of the function, to see, for example, where the end of a for loop is.

Obviously the interpreter is doing a fair amount of work at fix time. How much of the analysis of the control structures is used just for formatting the function, and how much, if any, is being used later when the function is being executed? In other words, when the interpreter is executing a function, does it have some sort of pre-computed data structure of the control structures that might be useful to me?

How much of this stuff could be made available to the APL programmer in an I-beam? Right now there are a couple of I-Beams that give info on syntax coloring, but I think that is the extent of it. There is probably other stuff that happens when a function is fixed that I would find useful when when writing my tracer too...
paulmansour
 
Posts: 418
Joined: Fri Oct 03, 2008 4:14 pm

Re: Analyzing Control Structures

Postby arcfide on Thu Dec 24, 2020 2:33 am

What sort of data are you looking to get out? Is your DSL APL syntax compatible? I presume yes given that you can fix it in Dyalog.

The Co-dfns compiler's parser can be extended to support a number of features, such as structured programming statements. I haven't done this yet because it hasn't reached a high enough priority, but in principle this would let you get a complete AST, and any number of analysis passes could be written around that AST to get answers for things you care about, whether integrated into Co-dfns or written as a separate set of utilities.

Is this a route you would find useful?
arcfide
 
Posts: 19
Joined: Fri Dec 09, 2011 3:53 am

Re: Analyzing Control Structures

Postby paulmansour on Thu Dec 24, 2020 2:48 pm

Thanks for the response.

Yes, the DSL is APL syntax compatible. So for running a script, I simply fix a function and let APL do the rest.

Line-by-line tracing without control structures is also pretty easy. With control structures, I need to keep track of all the line numbers for all control structures in some way. I think Co-Dfns is probably overkill for this.

I'm really just curious about how Dyalog does this, as they must be doing it for the Dyalog tracer. I'm curious how much work is done at fix time, and how much is done on the fly in the tracer.
paulmansour
 
Posts: 418
Joined: Fri Oct 03, 2008 4:14 pm


Return to Language

Who is online

Users browsing this forum: No registered users and 1 guest