📄 http:^^www.cs.wisc.edu^~glew^high-level-editting.html
字号:
Date: Tue, 05 Nov 1996 00:16:19 GMTServer: NCSA/1.5Content-type: text/htmlLast-modified: Thu, 12 Sep 1996 23:37:55 GMTContent-length: 6101<title>Glew on High-Level Editting</title><H1>Glew on High-Level Editting</H1>I have had a long-time interest in higher level editting operations,both for normal programming languages, and for hardware design - HDLs.<p>E.g. the MIT "Programmer's Apprentice".<p>This web page will serve as an achor for my own thoughts on the issue,particular for me to record scenarios to which this could apply.<H2>Semantic Split</H2>A common operation involves "spliting" a variable or parameter.<p>E.g. I need to edit GNU Emacs' dynamic abbreviations package toprovide completion to end of line instead of to end of word.Unfortunately, the package presently has a single variable "AbbreviationRegexp" which is using in two different contexts:(1) to dtermine the symbol that you are looking at,and (2) to determine the expansion.<p>I need to split this regexp so that I can control these capabilitiesseparately.Unfortunately, there is no way to do this without creating a completecopy of a call-tree of several dozen functions.And, of course, if I create this copy, then any changes to the originalwill not propagate to my copy, unless I succeed in subverting the original implementation,reimplement it in terms of the refined, split, semantics.<H2>Recursive Parameter Application</H2>I noticed this possible HLEO (High Level Editting Operation) whilemaintaining my "getnumber" package.<p> This package relies on recursion to provide a context-sensitivenumber parser that accepts most numeric formats. Each recognizer hasonly limited knowledge of syntax, but recurses through the top levelrecognizer to handle variants, thus obtaining modularity and easyextensibility.<p>Initially, the calling tree looked a bit like:<DL><DT><A NAME="Dgetnumber">Dgetnumber</A><DD> <DL> <DT>Dgetnumberlist<DD> <DL> <DT>Numeric formats, like decimal<DD> terminal - no further calls or recursion <DT>Expression formats, like +<DD> Recurses through <!WA0><A HREF="#Dgetnumber>Dgetnumber</A> to handle the subcomponents of the expression, after the operator has been recognized. </DL> </DL></DL><p>When I tried to create a variant of Dgetnumber - not a replacement, just a variant - I realized that I needed another level of indirection.Instead of the expression nodes calling Dgetnumber, they needed to call a variableTopLevelRecognizer for their recursion.To make this MP safe, this variable TopLevelRecognizer should not be a global variable,but should be a parameter passed to every function in the calling tree:<DL><DT><A NAME="Dgetnumber_Address">Dgetnumber_Address</A><DD> sets <A NAME="#TopLevelRecognizer1">TopLevelRecognizer=Dgetnumber_Address</A> when it calls Dgetnumberlist<DT><A NAME="Dgetnumber">Dgetnumber</A><DD> sets <A NAME="#TopLevelRecognizer2">TopLevelRecognizer=Dgetnumber</A> when it calls Dgetnumberlist <DL> <DT>Dgetnumberlist(with TopLevelRecognizer=Dgetnumber,...)<DD> <DL> <DT>f(TopLevelRecognizer,...): Numeric formats, like decimal<DD> terminal - no further calls or recursion <DT>f(TopLevelRecognizer,...): Expression formats, like +<DD> Recurses through TopLevelRecognizer, either <!WA1><A HREF="#TopLevelRecognizer1>Dgetnumber_Address</A> either <A HREF="#TopLevelRecognizer2>Dgetnumber</A> depending on usage, to handle the subcomponents of the expression, after the operator has been recognized. </DL> </DL></DL><p> Therefore, the high level editting operation is<em> in this calling tree, take all instances of the explicitly named operation or value X,and make them refer to a parameter that is passed along all paths the calling tree. </em>Similarly, the reverse operation may occasionally be useful.An interactive query framework would help.<p> Well, I just completed the above edit by hand. It took me morethan six (6) hours!!!! It was complicated by the fact that a semanticsplit of a type needed to be done, and by incomplete type checking offunction parameters in the C compiler I was using, but this emphasizesthe point: something that was asa simple to describe as above took anexcessively long time, because of the attention to detail that couldbe automated.<H4> Hidden Recursive Parameters </H4>A more specific example of this arose because I wanted to pass "hiddenstate" that is only useful to one of the lower functions in thecalling tree. It is not appropriate to make this extra info anexplicit parameter, because the information is only of interest to theupper level function that set it up, and the lower level function thatreceives it. None of the intervening levels of functions care aboutwhat is being passed.<p> I.e. we want to transparently communicate something between two different levels ofthe calling hierarchy, without affecting (or minimally affecting) the intermediate layers.<p> A typical naive solution is to do this with a global variable, but that is not MP safe.<p> Again, the "best" solution is to pass the hidden information as aparameter through all the intermediate levels. But, in addition tocreating the parameter, we also need to create the data types that canhide what is being passed. Furthermore, because it is quite likelythat there will need to be multiple, different, such instances ofcommunication, it is desirable to create a generic "data hidingmechanism: or "call-tree message passing mechanism" that can handleseveral such messages transparently.<p> All functions in such a calling tree might have a genericparameter "CallingTreeMessageList", which would be a composite object,e.g. a list, of messages with source, destination addresses, etc.<p> The high level routine might do something like this<pre> call generic-call-tree placing message to specialized-subfunction-variety</pre>while the receiver might do<pre> if I need extra info not in standard call parameters scan CallingTreeMessageList to see if it is there</pre><hr>$Header: /u/g/l/glew/public/html/RCS/high-level-editting.html,v 1.2 1995/12/31 07:54:17 glew Exp $
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -