Path: utzoo!mnetor!uunet!husc6!think!barmar From: barmar@think.COM (Barry Margolin) Newsgroups: comp.lang.lisp Subject: Re: lisp environments Message-ID: <13906@think.UUCP> Date: 17 Dec 87 22:51:03 GMT References: <487@PT.CS.CMU.EDU> <460@cresswell.quintus.UUCP> <13731@think.UUCP> <471@cresswell.quintus.UUCP> Sender: usenet@think.UUCP Reply-To: barmar@sauron.think.com.UUCP (Barry Margolin) Organization: Thinking Machines Corporation, Cambridge, MA Lines: 48 In article <471@cresswell.quintus.UUCP> pds@quintus.UUCP (Peter Schachte) writes: >In article <13731@think.UUCP>, barmar@think.COM (Barry Margolin) writes: >> ...The editor >> maintains a partial parse of the program in an auxiliary data structure. >> It uses event counts to update the parse as the user changes the code. > >So the Symbolics editor is a text AND structure editor! This approach >seems like it has the best of both worlds. But how partial is partial? Well, in the case of Lisp it is pretty simple, because Lisp has very simple syntax. Each line of the buffer is tagged with the lexical state at the beginning of the line; this specifies how deeply nested it is, whether it is in the middle of a string, and the function definition (or other top-level form) the line is part of. There are also some heuristics that speed things up, especially useful when the file isn't totally syntactically correct; for example, the parse state is reset whenever a line that begins with an open parenthesis is seen, so that leaving off a close paren will not screw up the parsing of the rest of the file. In the case of other languages such as Pascal, C, and Ada, a real parse tree is maintained, but I don't know much about its implementation. >And how long does it take to start up an edit on a fairly large file? The extra time it takes to parse the buffer is noticeable, but not intolerable, since it is interleaved with reading the file in from the file server. >Will it let you know you have a syntax error before you get far afield? >Or do you have to explicitly ASK the system? It generally only does syntax checking when you perform an operation on a syntactic unit. For example, when you ask to compile the current Lisp function it checks that the parentheses are balanced within that definition. There is a command that searches the buffer looking for unbalanced parentheses. The only automatic syntax check I'm aware of is done when a Lisp source file is being written out; it checks parentheses as it goes, and if it notices that they aren't balanced it asks whether you want to continue writing. --- Barry Margolin Thinking Machines Corp. barmar@think.com seismo!think!barmar