emacs-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] let octave-mode understand single-quoted strings


From: John W. Eaton
Subject: Re: [PATCH] let octave-mode understand single-quoted strings
Date: Tue, 5 Oct 2010 04:28:15 -0400

On  3-Sep-2010, Stefan Monnier wrote:

| >> I just implemented the single-quote string support based
| >> on code I previously wrote for perl-mode, where it's used for
| >> string-like thingies that often span multiple lines.  I.e. it came "for
| >> free".

In Octave and Matlab, character strings can't span multiple lines.

| BTW, where can I find a definition of the syntax of single-quoted
| strings (i.e. how does Octave distinguish a transpose from a single-quote
| starting a string)?
| The Octave docs I have don't say anything about it, AFAICT.

It's messy.

A single-quote character is recognized as a transpose operator if it

* Follows a ), ], or } character

    ( .. )'     => tranpose expression
    [ .. ]'     => tranpose matrix expression
    { .. }'     => tranpose cell array expression

* Follows a literal double-quoted string, or a literal single-quoted
  string if there is a space between the transpose operator and the
  final single-quote character that delimits the string.  For example

    "string"'   => transpose the character array 'string'
    'string' '  => transpose the character array 'string'
    'string''   => unterminated string constant
    'a''b'      => 1x3 character array containing the characters a'b

* Follows an identifier (variable or function name) unless the
  identifier could be a "command".  For example

    pwd '       => unterminated string constant
    (pwd)'      => transpose the output from the pwd function
    dir 'foo'   => list contents of the directory foo

* Follows an expression that references a structure element:

    a.b'        => return the transpose of a.b

  The Octave manual has a more complete description of how
  "command-style" parsing works (yes, this is ugly; it was implemented
  because it is required for compatibility with Matlab).

Does that help?

jwe



reply via email to

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