Reply to topic  [ 5 posts ] 
indenting and emacs 
Author Message

Joined: Sun Oct 18, 2009 6:46 pm
Posts: 10
Post indenting and emacs
Hi,

I usually edit yorick .i files in emacs. An annoyance for some time has been if a line doesn't end with ; then indenting isn't correct. For years I've been adding ;'s religiously but thought I'd ask if others are having this problem or if there's a fix. Esp. when editing code that doesn't contain ;'s (e.g. written by vi users) it becomes tiresome.

Thanks!


Mon May 14, 2012 6:39 am
Profile
Yorick Master

Joined: Tue Mar 07, 2006 10:31 pm
Posts: 125
Location: Meudon, France
Post Re: indenting and emacs
I do the same as you do. I think it's good coding style to end all lines with ";" anyway, even though it's not necessary for the parser.

<Flame>
Blame vi users.
</Flame>

It's not going to be easy to fix this behaviour in emacs since Yorick-mode uses C-mode for syntax highlighting and indenting.

Regards, Thibaut.


Tue May 15, 2012 7:35 am
Profile WWW
Yorick Master

Joined: Mon Nov 22, 2004 9:43 am
Posts: 354
Location: Livermore, CA, USA
Post Re: indenting and emacs
Yes. This is a feature, not a bug.

Yorick syntax was designed to be nearly identical to C or C++, which means that putting a great many editors into their C or C++ mode (e.g.- gedit, scintilla, bbedit, nedit, etc.) will give pretty much correct highlighting and indentation for much more than emacs. The emacs yorick mode is 10 times smaller than it would be without this commonality -- the indentation doesn't have to change at all, and the highlighting merely adds a few things like DOCUMENT comments to the exisiting emacs c-mode. None of this works without the semi-colon endings, so you are doing yourself a huge favor to add the semi-colons in all your yorick source, because someday you'll be forced to use an editor other than emacs, and it's C-mode will work on your yorick code as long as you have them.

The reason I permit omitting the semi-colons is to make it easier to type yorick statements directly at its command prompt. I should probably fix the yorick terminal mode so that it automatically adds the semi-colon if you just hit the return key, but of course that is impossible in a non-emacs terminal window, so I'm not highly motivated to do it.

Finally, I'll mention that a large fraction of the yorick parsing is devoted to artificial intelligence code that tries to figure out whether there are any missing semi-colons and to insert them in their proper place. It's called a "lexical tie-in" in parser theory, and it's a huge no-no -- you're NEVER supposed to design a language that needs lexical tie-ins to implement its parser. And, in fact, yorick has quite a few very ill-defined situations in which the lexical tie-in doesn't work the way you (or at least I) expect. That is, there are quite a few situations where permitting you to omit the semi-colon breaks the parser and makes it do surprising and not very nice things. No doubt you've trained yourself to use a programming style in which you never get bitten, as have I, but I believe because of those problems, yorick's grammar is not well-defined. By that I mean that I believe there is no complete formal description of the yorick grammar -- you certainly cannot write a yorick parser using only the standard yacc and lex UNIX tools. If I forced you to end all yorick statements with semi-colons, on the other hand, yorick does have a formal grammar which can be implemented using yacc/lex.

Someday I may force all yorick code read from text files (as opposed to stdin) to have proper semi-colon statement markers, so it can have a well-defined formal grammar. However, for the forseeable future, I use the same parser for stdin as for files, so for the time being you can omit semi-colons in files as well as in stdin.


Thu May 17, 2012 1:58 pm
Profile

Joined: Sun Oct 18, 2009 6:46 pm
Posts: 10
Post Re: indenting and emacs
OK, thanks for the replies! I hadn't checked the forum in a few days. I do end all my .i file lines w/ ;'s, but was wondering if I had to. Plus, when getting files from some colleagues of Dr. Munro and myself, who use primitIVe editors, there are no ;'s, and working w/ them in emacs is a pain.

I think you should make sure Yorick has a well-defined syntax, as well as semantics and semiotics, and that it's Turing complete, Goedel's thm. applies, and so on :)

Dave


Fri May 18, 2012 12:58 pm
Profile
Yorick Master

Joined: Mon Nov 22, 2004 9:43 am
Posts: 354
Location: Livermore, CA, USA
Post Re: indenting and emacs
If some good soul would write an elisp function that inserted missing semi-colons (in a buffer or region), that would ease the pain for Dr. Strozzi and me -- we could then automatically beautify ugly yorick code in emacs. Volunteers?


Fri May 18, 2012 10:05 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.