I’m not entirely sure I have the whole file, but I tried what you put on pastebin. At the end of the file though it has ...
which makes me think maybe there was more.
Anyway, looking at that Rutile/Anatase file you provided earlier, it does show a great deal of scoping so that’s good. It might be useful to you to either write a little command to print out the scope at the point and then bind it to a keystroke, or there is a plugin called ScopeAlways that you can toggle on and it puts the scope at the point in the status bar. (I prefer my own because the status bar has kind of tiny text and my eyes aren’t fantastic – I’ll include it at the end of the post just for reference; it’s quite basic and easy.)
So, I’m not entirely sure, but I think perhaps the issue you’re having is due to the fact that your blocks have no closing aspect to them. It looks like your end-block
context is trying to forward look to a comment character. I don’t think that’s working, and so you never pop a context off the stack. For example it looks like you’re trying to trap the !Atom
line and create a context on that. If you move the cursor a little past Titanium into empty space, you’ll see the scope stack still reads:
vhdl-mode: source.pcr meta.generic-block.pcr meta.generic-line-values.pcr
(Ignore the vhdl-mode
part, that’s simply because the scope sniffing utility is in my VHDL language package and I make sure any console output that comes out of my package is tagged with the name.)
Once you are in a context, it’s not scanning for everything else (usually – there is a method for prototype but use that with caution because it takes precedence over everything. It’s good for comments though).
Also everything works on a first-come-first-served preference. So if you match your generic block first, it’s not looking for your atomic block.
However this is a good place to start.
Some thoughts (I may start to ramble here – I keep going up and down, looking at different things and this little editor window is tiny.)
- Could you take out every comment line and would the program still know what to do?
- How does it know what to do? Is the order of cards fixed?
- I know
COMM
is a keyword for the top card. Is Name
also this way, or is that just ignored by the program?
- What is the
<--Space group symbol
text? Is it a command or is it ignored because the program recognized a P
command and it ignores everything after the pattern?
Reasons I ask, if the cards are in a fixed order, then you could just create a chained context card1
, card2
, card3
and then end when you got to the end of a group. That might be one strategy.
The two consecutive card method is working but either it’s popping something off the stack and immediately putting it back on or something. At the end of codewords though, it’s not shifting back well.
Not entirely sure why your null-number
variable isn’t matching before the regular number is. I think the regex for your null is a little off, but not in the way you’re using it (you can try it out at http://regexr.com/ and see that the exponential thing isn’t working, and it’ll try to find a match for the 0 in 0.23
when it should ignore that.) Still it matches 0.000 so that seems a little strange. EDIT: I think the exponential issue is that I don’t always put a +
in front of a positive exponent. If you change [+-]
to [+-]?
it seems to match exponents correctly.
It might make sense to start slightly fresh and just see if you can style Atom lines by themselves. I am also wondering if the cards work on the Fortran method of using the first character of every line to indicate something, though this kind of breaks on the Atom lines so I don’t know if that’s true. I wonder about the P
card though and I wonder how the FullProf program determines the dataset for each card. I think it might be the first two lines – Npr
Nph
Nba
makes me wonder if it’s listing the number of cards of various types but it doesn’t exactly match up with the data following so I don’t know for sure.
I’m a little scattered today, so I don’t know that this helped all that much. Maybe I can take a closer look at it ovre lunch or if I get a longer lull this afternoon. There are some weird things in there too like the inline comment not styling properly, etc.
And just in case it’s helpful, here’s my little scope sniffing command. Or, like I said, you can try that ScopeAlways plugin if you find that easier. I just didn’t like the pop up phantom with scope (though that’s also a possibility if you like that.)
class vhdlModeScopeSnifferCommand(sublime_plugin.TextCommand):
"""
My own scope sniffing command that prints to
console instead of a popup window.
"""
def run(self, edit):
"""ST3 Run Method"""
region = self.view.sel()[0]
sniff_point = region.begin()
print('vhdl-mode: {}'.format(self.view.scope_name(sniff_point)))