From 446aeec01d11440c25bbb1c3bbca227a6abe9eb7 Mon Sep 17 00:00:00 2001 From: Joe Mueller Date: Thu, 12 Feb 2015 14:45:16 -0800 Subject: fix problem with typdef class statements creating a fold point, expecting an endclass statement --- lexers/LexVerilog.cxx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'lexers') diff --git a/lexers/LexVerilog.cxx b/lexers/LexVerilog.cxx index 97fbaffa8..934838eb9 100644 --- a/lexers/LexVerilog.cxx +++ b/lexers/LexVerilog.cxx @@ -201,8 +201,9 @@ class LexerVerilog : public ILexerWithSubStyles { // states at end of line (EOL) during fold operations: // foldExternFlag: EOL while parsing an extern function/task declaration terminated by ';' - // foldWaitDisable: EOL while parsing wait or disable statement, terminated by "fork" or '(' - enum {foldExternFlag = 0x01, foldWaitDisableFlag = 0x02}; + // foldWaitDisableFlag: EOL while parsing wait or disable statement, terminated by "fork" or '(' + // typdefFlag: EOL while parsing typedef statement, terminated by ';' + enum {foldExternFlag = 0x01, foldWaitDisableFlag = 0x02, typedefFlag = 0x04}; // map using line number as key to store fold state information std::map foldState; @@ -878,6 +879,10 @@ void SCI_METHOD LexerVerilog::Fold(unsigned int startPos, int length, int initSt if (stateCurrent & foldWaitDisableFlag) { stateCurrent &= ~foldWaitDisableFlag; } + // typedef statements terminated by semicolon + if (stateCurrent & typedefFlag) { + stateCurrent &= ~typedefFlag; + } } // wait and disable statements containing '(' will not contain "fork" keyword, special processing is not needed if (ch == '(') { @@ -900,7 +905,6 @@ void SCI_METHOD LexerVerilog::Fold(unsigned int startPos, int length, int initSt if (styler.Match(j, "case") || styler.Match(j, "casex") || styler.Match(j, "casez") || - styler.Match(j, "class") || styler.Match(j, "function") || styler.Match(j, "generate") || styler.Match(j, "covergroup") || @@ -914,6 +918,10 @@ void SCI_METHOD LexerVerilog::Fold(unsigned int startPos, int length, int initSt (styler.Match(j, "module") && options.foldAtModule) || styler.Match(j, "begin")) { levelNext++; + } else if (styler.Match(j, "class")) { + // class does not introduce a block when used in a typedef statement + if (!(stateCurrent & typedefFlag)) + levelNext++; } else if (styler.Match(j, "fork")) { // fork does not introduce a block when used in a wait or disable statement if (stateCurrent & foldWaitDisableFlag) { @@ -946,6 +954,8 @@ void SCI_METHOD LexerVerilog::Fold(unsigned int startPos, int length, int initSt styler.Match(j, "wait")) { // fork does not introduce a block when used in a wait or disable statement stateCurrent |= foldWaitDisableFlag; + } else if (styler.Match(j, "typedef")) { + stateCurrent |= typedefFlag; } } if (atEOL) { -- cgit v1.2.3