jgm / skylighting

A Haskell syntax highlighting library with tokenizers derived from KDE syntax highlighting descriptions
189 stars 61 forks source link

Vhdl syntax highlighting fails whenever there is a process statement. #160

Closed fmirandabonomi closed 1 year ago

fmirandabonomi commented 1 year ago

This issue was encountered while using Quarto/Pandoc, then checked with skylighting 0.13.1.1 with GHC 9.2.5 under Windows 11 Pro version 10.0.22621

Given example.vhd:

entity dff is
    port (
        rst : in  bit;
        clk : in  bit;
        d   : in  bit;
        q   : out bit);
end dff;
architecture arch of dff is
begin
    ff:process (clk,rst)
    begin
        if rst = '1' then
            q <= '0';
        elsif clk'event and clk='1' then
            q <= d;
        end if;
    end process;
end architecture;

architecture arch2 of dff is
begin
    d <= '0';
end architecture;

executing C:\cabal\bin\skylighting.exe -f html -s vhdl example.vhd >example.html

Results in the following output vhdl-synthax-highlighting-output

Notice the bogus syntax error marked in line 14. This happens whenever a process statement is included in an architecture. Compare with line 19.

Expected output (as rendered by Kate version 22.08.1): vhdl-synthax-highlighting-expected

jgm commented 1 year ago

This is sufficient:

architecture arch of dff is
begin
    ff:process (clk,rst)
    begin
        if rst = '1' then
            q <= '0';
        elsif clk'event and clk='1' then
            q <= d;
        end if;
    end process;
end architecture;

I don't know the syntax. Can you trim this down to the smallest possible example that triggers the error?

Using --trace with skylighting will give you a record of what the state machine is doing and can help pinpoint the bug.

fmirandabonomi commented 1 year ago

Thanks for the fast reply. This is the smallest piece of code that, to my knowledge, triggers the issue.

architecture arch of device is
begin
    process
    begin
    end process;
end arch; 
c:\cabal\bin\skylighting.exe -f html -s vhdl example_2.vhd -n -T 2>trace.log 1>example_2.html

results in the following render skylighting-vhdl-minimal-example

The interesting fragments of the trace would be

...
 24 Trying rule Rule {rMatcher = RegExpr (RE {reString = "((?:\\b[A-Za-z_][A-Za-z0-9_]*\\b|\\\\[^\\\\]*\\\\))", reCaseSensitive = True}), rAttribute = DecValTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","arch_end")]}
 25 RegExpr MATCHED Just (DecValTok,"arch")
 26 CONTEXT STACK ["arch_end","architecture","start"]
...
162 CONTEXT STACK ["process","concurrent_stmt","arch_end","architecture","start"]
163 IncludeRules MATCHED Nothing
164 Trying rule Rule {rMatcher = RegExpr (RE {reString = "\\bend(\\s+postponed)?(\\s+process\\b)?(\\s+[A-Za-z_][A-Za-z0-9_]*)?\\s*;", reCaseSensitive = False}), rAttribute = SpecialCharTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop]}
165 RegExpr MATCHED Just (SpecialCharTok,"end process;")
166 CONTEXT STACK ["concurrent_stmt","arch_end","architecture","start"]
...
173 WordDetect MATCHED Nothing
174 CONTEXT STACK ["arch_end","architecture","start"]
175 IncludeRules MATCHED Nothing
176 Trying rule Rule {rMatcher = RegExpr (RE {reString = "\\bend(\\s+architecture\\b)?(\\s+%1)?\\s*;", reCaseSensitive = False}), rAttribute = ControlFlowTok, rIncludeAttribute = False, rDynamic = True, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop,Pop]}
177 Trying rule Rule {rMatcher = WordDetect "end", rAttribute = ErrorTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop,Pop,Push ("VHDL","expressionError")]}
178 WordDetect MATCHED Just (ErrorTok,"end")
179 CONTEXT STACK ["architecture","start"]
180 CONTEXT STACK ["start"]
181 CONTEXT STACK ["expressionError","start"]
...

Where the rule in line 176 should have matched but didn't. Skylighting doesn't emit any warning or error but when this happens in pandoc, it emits the following warning:

[WARNING] Could not highlight code block:
  Capture 1 not defined!

which I think points to the capture %1 in the regex rule. I think that this capture should refer to the match reported in line 25. That rule in vhdl.xml has the attribute beginRegion="ArchitectureRegion1" which I surmise preserve the capture. The rule tried in 176 and the one matched both have corresponding endRegion="ArchitectureRegion1" attributes. My guess is that process, which begins and ends its own region, interferes with the capture. With no process statement in between, the rule matches correctly.

Note: The rule fails to match even if you replace end arch; with end architecture; which is also valid vhdl, and should match the first part of the regex. I think the regex fails due to the missing capture and skylighting silently ignores the failure, treating it as a non-match.

For reference, Kate renders kate-vhdl-minimal-example

The whole trace.log is

Trying rule Rule {rMatcher = IncludeRules ("VHDL","preExpression"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = IncludeRules ("VHDL","blank"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = DetectSpaces, rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = Detect2Chars '-' '-', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","comment")]}
Trying rule Rule {rMatcher = Detect2Chars '/' '*', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","block_comment")]}
Trying rule Rule {rMatcher = Detect2Chars '<' '<', rAttribute = OtherTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","external_name")]}
Trying rule Rule {rMatcher = AnyChar (fromList "&*+,-./:<=>?@[]`|"), rAttribute = OtherTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = DetectChar '"', rAttribute = StringTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","string")]}
Trying rule Rule {rMatcher = DetectChar '\'', rAttribute = BaseNTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","attribute")]}
Trying rule Rule {rMatcher = Int, rAttribute = DecValTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","abstract_literal")]}
Trying rule Rule {rMatcher = WordDetect "entity", rAttribute = ControlFlowTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","entity")]}
Trying rule Rule {rMatcher = WordDetect "configuration", rAttribute = ControlFlowTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","configuration")]}
Trying rule Rule {rMatcher = WordDetect "architecture", rAttribute = ControlFlowTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","architecture")]}
WordDetect MATCHED Just (ControlFlowTok,"architecture")
CONTEXT STACK ["architecture","start"]
Trying rule Rule {rMatcher = IncludeRules ("VHDL","blank"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = DetectSpaces, rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
DetectSpaces MATCHED Just (NormalTok," ")
IncludeRules MATCHED Just (NormalTok," ")
Trying rule Rule {rMatcher = IncludeRules ("VHDL","blank"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = DetectSpaces, rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = Detect2Chars '-' '-', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","comment")]}
Trying rule Rule {rMatcher = Detect2Chars '/' '*', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","block_comment")]}
Trying rule Rule {rMatcher = RegExpr (RE {reString = "((?:\\b[A-Za-z_][A-Za-z0-9_]*\\b|\\\\[^\\\\]*\\\\))", reCaseSensitive = True}), rAttribute = DecValTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","arch_end")]}
RegExpr MATCHED Just (DecValTok,"arch")
CONTEXT STACK ["arch_end","architecture","start"]
Trying rule Rule {rMatcher = RegExpr (RE {reString = "\\bend(\\s+architecture\\b)?(\\s+%1)?\\s*;", reCaseSensitive = False}), rAttribute = ControlFlowTok, rIncludeAttribute = False, rDynamic = True, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop,Pop]}
Trying rule Rule {rMatcher = WordDetect "end", rAttribute = ErrorTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop,Pop,Push ("VHDL","expressionError")]}
CONTEXT STACK ["arch_of","arch_end","architecture","start"]
Trying rule Rule {rMatcher = IncludeRules ("VHDL","blank"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = DetectSpaces, rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
DetectSpaces MATCHED Just (NormalTok," ")
IncludeRules MATCHED Just (NormalTok," ")
Trying rule Rule {rMatcher = IncludeRules ("VHDL","blank"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = DetectSpaces, rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = Detect2Chars '-' '-', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","comment")]}
Trying rule Rule {rMatcher = Detect2Chars '/' '*', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","block_comment")]}
Trying rule Rule {rMatcher = WordDetect "of", rAttribute = KeywordTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop,Push ("VHDL","arch_ref")]}
WordDetect MATCHED Just (KeywordTok,"of")
CONTEXT STACK ["arch_end","architecture","start"]
CONTEXT STACK ["arch_ref","arch_end","architecture","start"]
Trying rule Rule {rMatcher = IncludeRules ("VHDL","blank"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = DetectSpaces, rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
DetectSpaces MATCHED Just (NormalTok," ")
IncludeRules MATCHED Just (NormalTok," ")
Trying rule Rule {rMatcher = IncludeRules ("VHDL","blank"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = DetectSpaces, rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = Detect2Chars '-' '-', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","comment")]}
Trying rule Rule {rMatcher = Detect2Chars '/' '*', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","block_comment")]}
Trying rule Rule {rMatcher = WordDetect "is", rAttribute = KeywordTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop,Push ("VHDL","block_declarative_stmt")]}
Trying rule Rule {rMatcher = IncludeRules ("VHDL","reference"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = DetectIdentifier, rAttribute = FunctionTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
DetectIdentifier MATCHED Just (FunctionTok,"device")
IncludeRules MATCHED Just (FunctionTok,"device")
Trying rule Rule {rMatcher = IncludeRules ("VHDL","blank"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = DetectSpaces, rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
DetectSpaces MATCHED Just (NormalTok," ")
IncludeRules MATCHED Just (NormalTok," ")
Trying rule Rule {rMatcher = IncludeRules ("VHDL","blank"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = DetectSpaces, rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = Detect2Chars '-' '-', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","comment")]}
Trying rule Rule {rMatcher = Detect2Chars '/' '*', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","block_comment")]}
Trying rule Rule {rMatcher = WordDetect "is", rAttribute = KeywordTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop,Push ("VHDL","block_declarative_stmt")]}
WordDetect MATCHED Just (KeywordTok,"is")
CONTEXT STACK ["arch_end","architecture","start"]
CONTEXT STACK ["block_declarative_stmt","arch_end","architecture","start"]
Trying rule Rule {rMatcher = IncludeRules ("VHDL","blank"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = DetectSpaces, rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = Detect2Chars '-' '-', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","comment")]}
Trying rule Rule {rMatcher = Detect2Chars '/' '*', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","block_comment")]}
Trying rule Rule {rMatcher = IncludeRules ("VHDL","block_declarative_start_expr"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = IncludeRules ("VHDL","package_declarative_start_expr"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = WordDetect "component", rAttribute = ControlFlowTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","component")]}
Trying rule Rule {rMatcher = IncludeRules ("VHDL","process_declarative_start_expr"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = WordDetect "package", rAttribute = ControlFlowTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","package")]}
Trying rule Rule {rMatcher = WordDetect "type", rAttribute = OtherTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","type")]}
Trying rule Rule {rMatcher = WordDetect "function", rAttribute = AttributeTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","function")]}
Trying rule Rule {rMatcher = WordDetect "procedure", rAttribute = KeywordTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","procedure")]}
Trying rule Rule {rMatcher = WordDetect "shared", rAttribute = KeywordTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = WordDetect "impure", rAttribute = KeywordTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = WordDetect "pure", rAttribute = KeywordTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = WordDetect "view", rAttribute = KeywordTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","view")]}
Trying rule Rule {rMatcher = Keyword (KeywordAttr {keywordCaseSensitive = False, keywordDelims = fromList "\t\n !%&()*+,-./:;<=>?[\\]^{|}~"}) (Right (CaseInsensitiveWords (fromList ["attribute","constant","signal","type","variable"]))), rAttribute = OtherTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","signal")]}
Trying rule Rule {rMatcher = WordDetect "for", rAttribute = ControlFlowTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","for_block_decl")]}
Trying rule Rule {rMatcher = WordDetect "begin", rAttribute = ControlFlowTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop,Push ("VHDL","concurrent_stmt")]}
WordDetect MATCHED Just (ControlFlowTok,"begin")
CONTEXT STACK ["arch_end","architecture","start"]
CONTEXT STACK ["concurrent_stmt","arch_end","architecture","start"]
Trying rule Rule {rMatcher = IncludeRules ("VHDL","blank"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = DetectSpaces, rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
DetectSpaces MATCHED Just (NormalTok,"    ")
IncludeRules MATCHED Just (NormalTok,"    ")
Trying rule Rule {rMatcher = IncludeRules ("VHDL","blank"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = DetectSpaces, rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = Detect2Chars '-' '-', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","comment")]}
Trying rule Rule {rMatcher = Detect2Chars '/' '*', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","block_comment")]}
Trying rule Rule {rMatcher = IncludeRules ("VHDL","pop_end"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = WordDetect "end", rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = True, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop]}
Trying rule Rule {rMatcher = IncludeRules ("VHDL","concurrent_label"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = RegExpr (RE {reString = "\\b(?!(process|constant|signal|variable)\\b)\\b[A-Za-z_][A-Za-z0-9_]*(?=\\s*:(?!=))", reCaseSensitive = True}), rAttribute = DecValTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","concurrent_stmt_label")]}
CONTEXT STACK ["concurrent_stmt_item","concurrent_stmt","arch_end","architecture","start"]
Trying rule Rule {rMatcher = IncludeRules ("VHDL","blank"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = DetectSpaces, rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = Detect2Chars '-' '-', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","comment")]}
Trying rule Rule {rMatcher = Detect2Chars '/' '*', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","block_comment")]}
Trying rule Rule {rMatcher = IncludeRules ("VHDL","concurrent_stmt_item_start"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = WordDetect "postponed", rAttribute = KeywordTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = WordDetect "package", rAttribute = ControlFlowTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop,Push ("VHDL","package")]}
Trying rule Rule {rMatcher = WordDetect "type", rAttribute = OtherTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop,Push ("VHDL","type")]}
Trying rule Rule {rMatcher = WordDetect "function", rAttribute = AttributeTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop,Push ("VHDL","function")]}
Trying rule Rule {rMatcher = WordDetect "procedure", rAttribute = KeywordTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop,Push ("VHDL","procedure")]}
Trying rule Rule {rMatcher = WordDetect "process", rAttribute = SpecialCharTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop,Push ("VHDL","process")]}
WordDetect MATCHED Just (SpecialCharTok,"process")
CONTEXT STACK ["concurrent_stmt","arch_end","architecture","start"]
CONTEXT STACK ["process","concurrent_stmt","arch_end","architecture","start"]
IncludeRules MATCHED Just (SpecialCharTok,"process")
Trying rule Rule {rMatcher = RegExpr (RE {reString = "\\bend(\\s+postponed)?(\\s+process\\b)?(\\s+[A-Za-z_][A-Za-z0-9_]*)?\\s*;", reCaseSensitive = False}), rAttribute = SpecialCharTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop]}
Trying rule Rule {rMatcher = WordDetect "end", rAttribute = ErrorTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop,Push ("VHDL","expressionError")]}
CONTEXT STACK ["process_params","process","concurrent_stmt","arch_end","architecture","start"]
Trying rule Rule {rMatcher = IncludeRules ("VHDL","blank"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = DetectSpaces, rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
DetectSpaces MATCHED Just (NormalTok,"    ")
IncludeRules MATCHED Just (NormalTok,"    ")
Trying rule Rule {rMatcher = IncludeRules ("VHDL","blank"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = DetectSpaces, rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = Detect2Chars '-' '-', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","comment")]}
Trying rule Rule {rMatcher = Detect2Chars '/' '*', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","block_comment")]}
Trying rule Rule {rMatcher = IncludeRules ("VHDL","enclosed_association_list"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = DetectChar '(', rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","association_list")]}
Trying rule Rule {rMatcher = WordDetect "is", rAttribute = KeywordTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop,Push ("VHDL","process_decl")]}
CONTEXT STACK ["process","concurrent_stmt","arch_end","architecture","start"]
CONTEXT STACK ["process_decl","process","concurrent_stmt","arch_end","architecture","start"]
Trying rule Rule {rMatcher = IncludeRules ("VHDL","blank"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = DetectSpaces, rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = Detect2Chars '-' '-', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","comment")]}
Trying rule Rule {rMatcher = Detect2Chars '/' '*', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","block_comment")]}
Trying rule Rule {rMatcher = IncludeRules ("VHDL","process_declarative_start_expr"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = WordDetect "package", rAttribute = ControlFlowTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","package")]}
Trying rule Rule {rMatcher = WordDetect "type", rAttribute = OtherTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","type")]}
Trying rule Rule {rMatcher = WordDetect "function", rAttribute = AttributeTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","function")]}
Trying rule Rule {rMatcher = WordDetect "procedure", rAttribute = KeywordTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","procedure")]}
Trying rule Rule {rMatcher = WordDetect "shared", rAttribute = KeywordTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = WordDetect "impure", rAttribute = KeywordTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = WordDetect "pure", rAttribute = KeywordTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = WordDetect "view", rAttribute = KeywordTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","view")]}
Trying rule Rule {rMatcher = Keyword (KeywordAttr {keywordCaseSensitive = False, keywordDelims = fromList "\t\n !%&()*+,-./:;<=>?[\\]^{|}~"}) (Right (CaseInsensitiveWords (fromList ["attribute","constant","signal","type","variable"]))), rAttribute = OtherTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","signal")]}
Trying rule Rule {rMatcher = WordDetect "begin", rAttribute = SpecialCharTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop,Push ("VHDL","sequential_stmt")]}
WordDetect MATCHED Just (SpecialCharTok,"begin")
CONTEXT STACK ["process","concurrent_stmt","arch_end","architecture","start"]
CONTEXT STACK ["sequential_stmt","process","concurrent_stmt","arch_end","architecture","start"]
Trying rule Rule {rMatcher = IncludeRules ("VHDL","blank"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = DetectSpaces, rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
DetectSpaces MATCHED Just (NormalTok,"    ")
IncludeRules MATCHED Just (NormalTok,"    ")
Trying rule Rule {rMatcher = IncludeRules ("VHDL","blank"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = DetectSpaces, rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = Detect2Chars '-' '-', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","comment")]}
Trying rule Rule {rMatcher = Detect2Chars '/' '*', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","block_comment")]}
Trying rule Rule {rMatcher = IncludeRules ("VHDL","pop_end"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = WordDetect "end", rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = True, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop]}
WordDetect MATCHED Nothing
CONTEXT STACK ["process","concurrent_stmt","arch_end","architecture","start"]
IncludeRules MATCHED Nothing
Trying rule Rule {rMatcher = RegExpr (RE {reString = "\\bend(\\s+postponed)?(\\s+process\\b)?(\\s+[A-Za-z_][A-Za-z0-9_]*)?\\s*;", reCaseSensitive = False}), rAttribute = SpecialCharTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop]}
RegExpr MATCHED Just (SpecialCharTok,"end process;")
CONTEXT STACK ["concurrent_stmt","arch_end","architecture","start"]
Trying rule Rule {rMatcher = IncludeRules ("VHDL","blank"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = DetectSpaces, rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = Detect2Chars '-' '-', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","comment")]}
Trying rule Rule {rMatcher = Detect2Chars '/' '*', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","block_comment")]}
Trying rule Rule {rMatcher = IncludeRules ("VHDL","pop_end"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = WordDetect "end", rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = True, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop]}
WordDetect MATCHED Nothing
CONTEXT STACK ["arch_end","architecture","start"]
IncludeRules MATCHED Nothing
Trying rule Rule {rMatcher = RegExpr (RE {reString = "\\bend(\\s+architecture\\b)?(\\s+%1)?\\s*;", reCaseSensitive = False}), rAttribute = ControlFlowTok, rIncludeAttribute = False, rDynamic = True, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop,Pop]}
Trying rule Rule {rMatcher = WordDetect "end", rAttribute = ErrorTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop,Pop,Push ("VHDL","expressionError")]}
WordDetect MATCHED Just (ErrorTok,"end")
CONTEXT STACK ["architecture","start"]
CONTEXT STACK ["start"]
CONTEXT STACK ["expressionError","start"]
Trying rule Rule {rMatcher = Detect2Chars '-' '-', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","comment")]}
Trying rule Rule {rMatcher = DetectChar ';', rAttribute = ErrorTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop]}
FALLTHROUGH Just (ErrorTok," ")
Trying rule Rule {rMatcher = Detect2Chars '-' '-', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","comment")]}
Trying rule Rule {rMatcher = DetectChar ';', rAttribute = ErrorTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop]}
FALLTHROUGH Just (ErrorTok,"arch")
Trying rule Rule {rMatcher = Detect2Chars '-' '-', rAttribute = CommentTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Push ("VHDL","comment")]}
Trying rule Rule {rMatcher = DetectChar ';', rAttribute = ErrorTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop]}
DetectChar MATCHED Just (ErrorTok,";")
CONTEXT STACK ["start"]
Trying rule Rule {rMatcher = IncludeRules ("VHDL","preExpression"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = IncludeRules ("VHDL","blank"), rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
Trying rule Rule {rMatcher = DetectSpaces, rAttribute = NormalTok, rIncludeAttribute = False, rDynamic = False, rCaseSensitive = True, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = []}
DetectSpaces MATCHED Just (NormalTok," ")
IncludeRules MATCHED Just (NormalTok," ")
IncludeRules MATCHED Just (NormalTok," ")
fmirandabonomi commented 1 year ago

Possible workaround

The problem is almost certainly because of the mishandling of nested regions in conjunction with capture. Those are used by the syntax definition to check that the correct identifier is included in the end part of a statement, yielding an error if another identifier is used.

A possible workaround would be to replace all the instances of %1 in vhdl.xml with &identifier;, which negates the check but yields the expected highlighting. As syntax highlighting is not the same as syntax checking, this would probably be still acceptable.

After downloading vhdl.xml

cat vhdl.xml | grep %1

yields

                 String="&bos;end(\s+package\b)?(\s+%1)?\s*;" endRegion="PackageRegion1"/>
                 String="&bos;end(\s+package\s+body\b)?(\s+%1)?\s*;" endRegion="PackageBodyRegion1"/>     
                 String="&bos;end(\s+architecture\b)?(\s+%1)?\s*;" endRegion="ArchitectureRegion1"/>      
                 String="&bos;end(\s+entity)?(\s+%1)?\s*;" endRegion="EntityRegion1"/>
                 String="&bos;end(\s+configuration\b)?(\s+%1)?\s*;" endRegion="ConfigurationRegion1"/>    
                 String="&bos;end(\s+context)?(\s+%1)?\s*;" endRegion="ContextRegion1"/>
                 String="&bos;end\s+component\b(\s+%1)?\s*;" endRegion="ComponentRegion1"/>

so the only uses of %1 in the file are as prevously described and it's safe to do a direct replacement.

>sed "s/%1/\&identifier;/" vhdl.xml >vhdl_workaround.xml

then

\cabal\bin\skylighting -f html -s vhdl -d vhdl_workaround.xml -n -T example_2.vhd 1>example_2.html 2>example_2.log

yields the expected output

skylighting-vhdl-minimal-workaround

and the trace now shows that the correct rule matches.

...
175 CONTEXT STACK ["arch_end","architecture","start"]
176 IncludeRules MATCHED Nothing
177 Trying rule Rule {rMatcher = RegExpr (RE {reString = "\\bend(\\s+architecture\\b)?(\\s+(?:\\b[A-Za-z_][A-Za-z0-9_]*\\b|\\\\[^\\\\]*\\\\))?\\s*;", reCaseSensitive = False}), rAttribute = ControlFlowTok, rIncludeAttribute = False, rDynamic = True, rCaseSensitive = False, rChildren = [], rLookahead = False, rFirstNonspace = False, rColumn = Nothing, rContextSwitch = [Pop,Pop]}
178 RegExpr MATCHED Just (ControlFlowTok,"end arch;")
179 CONTEXT STACK ["architecture","start"]
180 CONTEXT STACK ["start"]
...

This workaround should be useful to render vhdl syntax highlighting until the root issue (handling of capture in nested heterogeneous regions) is solved.

jgm commented 1 year ago

The pandoc warning about "Capture 1" is because pandoc was compiled with an older version of skylighting; this issue has been fixed, so it's not what is going on here (or you would have had the same error from skylighting).

jgm commented 1 year ago

I can confirm that when it tries to retrieve the earlier match %1, it gets Nothing. So that is the problem, but I still don't know why the earlier match isn't being retrieved.

jgm commented 1 year ago

The reason we no longer get the "Capture 1" warning is

commit 90156ce692a73b782fc5a0d9bcb38eb4e4c4413f

    getCapture: fail instead of throwing error if dynamic match not found.

    I believe this is the intended behavior for StringDetect, judging
    from examples in the documentation.

But I think your analysis is correct. The match isn't being preserved long enough for it to be retrieved at this point - still don't see why.

jgm commented 1 year ago

From KDE syntax highlighting docs:

If dynamic is true, a rule can use placeholders representing the text matched by a regular expression rule that switched to the current context in its string or char attributes. In a string, the placeholder %N (where N is a number) will be replaced with the corresponding capture N from the calling regular expression, starting from 1. In a char the placeholder must be a number N and it will be replaced with the first character of the corresponding capture N from the calling regular expression.

It is important to mention that a text captured in a RegExpr rule is only stored for the switched context, specified in its context attribute.

I think this is our problem. We just have one list of captures; it needs to be indexed to the context.

jgm commented 1 year ago

Thanks for reporting this error -- I think the fix is going to improve highlighting for some other syntaxes as well!