![](https://secure.gravatar.com/avatar/c5ae4f9aa0d3a9bd5376e92b322c3e50.jpg?s=120&d=mm&r=g)
Hi, I was trying to define a pretty printing environment for matlab files. The basic requirements that I have are % Numbers should be highlighted in a different color % Identify floating point numbers 1.1 and 1e-3. % Identify brackets % ()[]{} % Identify Punctuation % ,;<=> ... % Identify Operators % ^ + - / * .^ .* % Idenfity strings (enclosed in ' ' and " ") % Identify lines starting with % as comments. Show them % a different color. Identify %{ ... %} blocks as comments % identifiers function return case if else elseif do for while end % variables gt,lt,gt,lt,amp,abs,acos,acosh,acot,acoth,acsc,acsch, [snip].... a huge list The syntax is similar to both perl and MP. I had a look at the verb-*.tex files and tried to write verb-matlab. My attempt is attached. However, it does not work correctly. There are somethings that I could not figure out. 1. How to change the comment identifier. Matlab uses % as line comments and %{ .... %} as block comments. 2. For some reason Matlab variables are not recognized. 3. The punctuations are not identified. 4. '...' is not recognized as a string. The ' is output as a right quotation mark and not _neutral_ '. What would be a good way to include tex commands in the comments? Matlab recognizes %% as a special comment (begining of a cell). Is it possible to somehow translate %% into \MATLABcell, which is \bf by default but the behaviour can be changed if desired? See attachment verb-matlab.tex for my attempt and test.tex for an example. Thanks Aditya -- Aditya Mahajan, EECS Systems, University of Michigan http://www.eecs.umich.edu/~adityam || Ph: 7342624008
![](https://secure.gravatar.com/avatar/565476157eb3895a9c928ffce26d988d.jpg?s=120&d=mm&r=g)
Aditya Mahajan wrote:
Hi,
I was trying to define a pretty printing environment for matlab files. The basic requirements that I have are
The syntax is similar to both perl and MP. I had a look at the verb-*.tex files and tried to write verb-matlab. My attempt is attached.
If you have to change any of the actual syntax rules (like for comments etc.), then you have to be brave and create a fully new definition. That may sound like a very daunting task, but it is not as hard as you may think, just something to be done meticulously. The verb-xxxx definitions are rather straightforward state engines that use character codes as command tokens. Cheers, Taco
![](https://secure.gravatar.com/avatar/c5ae4f9aa0d3a9bd5376e92b322c3e50.jpg?s=120&d=mm&r=g)
On Wed, 15 Mar 2006, Taco Hoekwater wrote:
Aditya Mahajan wrote:
Hi,
I was trying to define a pretty printing environment for matlab files. The basic requirements that I have are
The syntax is similar to both perl and MP. I had a look at the verb-*.tex files and tried to write verb-matlab. My attempt is attached.
If you have to change any of the actual syntax rules (like for comments etc.), then you have to be brave and create a fully new definition.
The syntax is quite similar to MP. I will see if I can make the corresponding changes for things to work.
That may sound like a very daunting task, but it is not as hard as you may think, just something to be done meticulously. The verb-xxxx definitions are rather straightforward state engines that use character codes as command tokens.
Is this documented somewhere? Even the source files (verb-*.tex) did not have too many hints on what is going on. Should I also look into some other files? Thanks, Aditya
![](https://secure.gravatar.com/avatar/565476157eb3895a9c928ffce26d988d.jpg?s=120&d=mm&r=g)
Aditya Mahajan wrote:
That may sound like a very daunting task, but it is not as hard as you may think, just something to be done meticulously. The verb-xxxx definitions are rather straightforward state engines that use character codes as command tokens.
Is this documented somewhere?
I don't know. If anybody else knows, please tell me. If not, I'll jot down some stuff. Cheers, Taco
![](https://secure.gravatar.com/avatar/c5ae4f9aa0d3a9bd5376e92b322c3e50.jpg?s=120&d=mm&r=g)
<--- On Mar 16, Taco Hoekwater wrote --->
Aditya Mahajan wrote:
That may sound like a very daunting task, but it is not as hard as you may think, just something to be done meticulously. The verb-xxxx definitions are rather straightforward state engines that use character codes as command tokens.
Is this documented somewhere?
I don't know. If anybody else knows, please tell me. If not, I'll jot down some stuff.
Actually the explaination in verb-ini.tex is pretty good. I had somehow missed reading it earlier. I vaguely understand how the whole mechanism is working and managed to obtain a partial solution (attached). I have a deadline for submission and right now this will have to do. The only features missing are identifying line and block comments and a meachism to add tex markup in comments. I need to understand verb-jv/js more clearly to incorporate these changes. Thanks, Aditya -- Aditya Mahajan, EECS Systems, University of Michigan http://www.eecs.umich.edu/~adityam || Ph: 7342624008
![](https://secure.gravatar.com/avatar/565476157eb3895a9c928ffce26d988d.jpg?s=120&d=mm&r=g)
Aditya Mahajan wrote:
Actually the explaination in verb-ini.tex is pretty good. I had somehow missed reading it earlier. I vaguely understand how the whole mechanism is working and managed to obtain a partial solution (attached). I have a
When you feel it is finished, please e-mail it to Patrick for inclusion in the third party modules section of contextgarden.net (Nikolai, do you remember your verb-c ? :-)) Greetings, Taco
participants (2)
-
Aditya Mahajan
-
Taco Hoekwater