bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#703: Octave comments in emacs


From: Rosen Diankov
Subject: bug#703: Octave comments in emacs
Date: Thu, 21 Aug 2008 14:26:55 -0400

> Maybe we could use a rough heuristic to handle most of the cases.  A '
> character that occurs before "[=(] *" is probably the beginning of a
> single quoted string, not a transpose operator.  WDYT?
I can think of a lot of cases where this would break.

The proper way of doing it is to tokenize a line and emulate a simple
parser. Although the rules that will be used to parse octave
expressions don't need to be thourough, they have to be sufficient
enough to detect transposition vs strings.

As far as I know, context free grammars are strictly more powerful
than regular expressions. A simple example is keeping track of [] and
(). So it might be impossible to generate a regular expression doing
what we want it to do.

Environments like Visual Studio and Eclipse do dynamic code analysis
all the time, so I would be surprised if emacs doesn't have some
equivalent parsing functionality.

Rosen,

2008/8/21 Chong Yidong <address@hidden>:
> Stefan Monnier <address@hidden> wrote:
>
>> > Is there a way to assign two different syntax rules for the same
>> > character in emacs? Ie, one where ' is treated as a string quote
>> > (and suppresses the syntax elements inside the quotes), and one
>> > where it is treated as a suffix operator.
>>
>> Yes, there is, using the `syntax-table' property.  A common way to set
>> this property is via the font-lock-syntactic-keywords variable.
>>
>> So all it takes is a regexp good enough to distinguish the two cases
>
> Kurt Hornik <address@hidden> wrote:
>
>> Octave mode has never provided syntax support for single quoted
>> strings because there is no way (short of actually parsing the code)
>> of telling these apart from single quotes used for transposition.
>
> Maybe we could use a rough heuristic to handle most of the cases.  A '
> character that occurs before "[=(] *" is probably the beginning of a
> single quoted string, not a transpose operator.  WDYT?
>






reply via email to

[Prev in Thread] Current Thread [Next in Thread]