There is no bundle for Verilog HDL, but it has a lot in common with C and Pascal, so I duplicated the C language and have been hacking on that to get the syntax coloration mostly working. I've run into a bit of trouble with the constant expression syntax though. In Verilog constants have this form: 8'b00100011 (8 bit binary) 6'o35 (6 bit octal) 12'h3A2 (12 bit hex)
The initial number is optional, so 'b10110 would be a 5 bit binary constant. In addition to numbers, z and ? can also appear sometimes to indicate high impedance or indeterminate values. I've tried the following syntax for the binary constants:
...|([0-9]*)'b[0-1zZ?]*)|...
When I hit the test button it highlights everything from the b on. I'm guessing it is not able to escape the single quote. I've also tried escaping the b as well and it didn't make any difference. Is there a way around this? Is there somewhere I can find the detailed syntax rules for the matching expressions and bundles in general? I did a quick look through the WIKI and didn't see anything obvious.
On Dec 4, 2005, at 5:27 PM, Jeff DuMonthier wrote:
...|([0-9]*)'b[0-1zZ?]*)|...
When I hit the test button it highlights everything from the b on.
If this is really what you have typed in, then you are missing an opening parenthesis. The parenthesis at the end doesn't seem to have been opened.
Haris
Sorry, cut and paste error. The whole string is this. The verilog binary constant is the first one, the rest is from the C definition:
match = '\b((([0-9]*)'b[0-1zZ?]*)|0(x|X)[0-9a-fA-F]*)|(([0-9]+.?[0 -9]*)|(.[0-9]+))((e|E)(+|-)?[0 -9]+)?)(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\b';
The highlighting, which I assume indicates an error, starts at the b after the probably not escaped second '.
On Dec 4, 2005, at 9:06 PM, Charilaos Skiadas wrote:
On Dec 4, 2005, at 5:27 PM, Jeff DuMonthier wrote:
...|([0-9]*)'b[0-1zZ?]*)|...
When I hit the test button it highlights everything from the b on.
If this is really what you have typed in, then you are missing an opening parenthesis. The parenthesis at the end doesn't seem to have been opened.
Haris
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
On Dec 4, 2005, at 8:19 PM, Jeff DuMonthier wrote:
match = '\b((([0-9]*)'b[0-1zZ?]*)|0(x|X)[0-9a-fA-F]*)|(([0-9]+.? [0-9]*)|(.[0-9]+))((e|E)(+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f|ll|LL| ull|ULL)?\b';
The highlighting, which I assume indicates an error, starts at the b after the probably not escaped second '.
Try maybe adding parentheses enclosing everything but the \b's, like so: \b(((([0-9]*)'b[0-1zZ?]*)|0(x|X)[0-9a-fA-F]*)|(([0-9]+.?[0-9]*)|(. [0-9]+))((e|E)(+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?)\b
If you send me the whole syntax and some sample examples and who they are supposed to work, I can give it a try over here. The highlighting doesn't necessarily indicate an error. The question is what scope you are getting on those things, which you can see by shift-cntrl-p.
Haris
You had a parenthesis wrong further down the line I think, try this:
match = "\b(((([0-9]*)'b[0-1zZ?]*)|0(x|X)[0-9a-fA-F]*)|(([0-9]+.? [0-9]*)|(.[0-9]+))((e|E)(+|-)?[0-9]+)?(L|l|UL|ul|u|U|F|f|ll|LL|ull| ULL)?)\b";
This correctly highlights the binary things, though it does not recognize them if they start with ', not sure why not yet, but if you are worried about the ', just use double quotes on the outsides, and then you don't have to escape it. Let's just hope you don't have to match both ' and " at the same time.
Ok, I now know why it doesn't recognize then when you start with '. The \b is a "word boundary" so checks changes from what is happening before. I don't understand it myself very well, but your problem here is that \b followed by a non-number will expect a number before it, and so it won't get triggered unless there is a number before the '. So if you remove the \b's from both ends, it should work, though maybe it breaks elsewhere. I'm sure there is a better answer, but I'll leave someone with more experience with the oniguruma syntax answer that. I guess it depends on what is allowed to precede the ' in the overall syntax etc.
Haris
On 5/12/2005, at 3:53, Charilaos Skiadas wrote:
[...] if you are worried about the ', just use double quotes on the outsides, and then you don't have to escape it. Let's just hope you don't have to match both ' and " at the same time.
Help -> Syntax Highlight:
Notice that if you edit the property list inside TextMate, two improvements have been made to the format:
1. Single quoted strings doesn't support escape code, so all backslash characters are literal. It converts two single quotes into one. E.g.: 'That''s neat'.
2. Double quoted strings only interpret \ as part of an escape character when the next character is either " or , in all other cases, the \ is literal (what would normally be \ in the normal property list format).
So to include both use "["']" or '["'']'.
Thanks for the suggestions. This seems to do the trick:
match = "('b[0-1zZ?]*)|('o[0-7zZ?]*)|('h[0-9a-fA-FzZ?]*)|(\b(([0-9]+.?[0 -9]*)|(.[0-9]+))((e|E)(+|-)?[0-9]+)?)\b";
The numbers preceding the single quotes are actually picked up as separate constants from the parts beginning with single quotes, which is a bit counterintuitive, but it works.