[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-source-highlight] postscript style for source-hightlight
From: |
jeffz |
Subject: |
Re: [Help-source-highlight] postscript style for source-hightlight |
Date: |
Sat, 24 Mar 2007 21:59:11 +1100 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
On Sat, Mar 24, 2007 at 11:20:24AM +0100, Lorenzo Bettini wrote:
> address@hidden wrote:
> >Hi
> >
>
> Hi Jeff and welcome to the list
>
Thanks
> >I recently discovered source-highlight, it appears to be a very useful
> >program.
> >
> >
> >However, when using the postscript.lang as a source language, it doesn't
> >handle % within strings (%) correctly.
> >
>
> so (%) is to be considered as a string?
> in particular everything between ( and ) should be considered as a string?
Yes
> >eg, the following is treated as a comment and print is highlighted as
> >such, where instead because % is inside ( ) it should be treated as part
> >of a string. (%) print
> >
> >I first tried adding "string = '\(.*\)'" to postscript.lang, this
> >suceeded in highlighting strings correctly, but % inside ( ) was still
> >making the rest of the line a comment.
>
> mhh... probably because your definition comes after the definition of %
> comment?
I put my string definition before the regular comment definition.
> >
> >I tried changing comment start "%" to comment start "(\(.*\))*(?=)%" but
> >this appears to be wrong, as source-highlight prints the following:
> >
> >source-highlight: /usr/include/boost/shared_ptr.hpp:253: T*
> >boost::shared_ptr<T>::operator->() const [with T = RegExpFormatter]:
> >Assertion `px != 0' failed.
> >Aborted
>
> yes probably this generates a regular expression that's wrong...
>
> >
> >Are there any gurus able to assist?
> >
>
> Although I don't know postscript I can try to fix this problem.
>
> I'd need an input test file (in postscript) with % used in several
> context, i.e., when it should be treated as a comment and some examples
> of valid postscript strings (for instance, can ( ) strings be nested?
> can ( or ) be escaped?)
>
According to the PostScript Language Reference manual, a comment is
defined as:
"Any occurrence of the character % outside a string introduces a comment.
The comment consists of all characters between the % and the next newline
or form feed, including regular, delimiter, space, and tab characters."
again, referring to the red book on strings:
"Literal Text Strings
A literal text string consists of an arbitrary number of characters
enclosed in ( and ). Any characters may appear in the string other than
(, ), and \, which must be treated specially. Balanced pairs of
parentheses in the string require no special treatment.
The following lines show several valid strings:
(This is a string)
(Strings may contain newlines
and such.)
(Strings may contain special characters *!&}^% and
balanced parentheses ( ) (and so on).)
(The following is an empty string.)
()
(It has 0 (zero) length.)
Within a text string, the \ (backslash) character is treated as an
“escape” for various purposes, such as including newline characters,
unbalanced parentheses, and the \ character itself in the string."
In summary, an example of input would be.
% This is a comment
(This is a % (percent) inside a string)
> hope to hear from you soon
> cheers
> Lorenzo
Thanks for your quick reply
Jeff
> P.S. yesterday I released 2.6 of source-highlight
>
> --
> Lorenzo Bettini, PhD in Computer Science, DSI, Univ. di Firenze
> ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
> HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
> BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
> http://www.gnu.org/software/src-highlite
> http://www.gnu.org/software/gengetopt
> http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
>