[svn]
r6764: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel:
ScanLexer.n ScanState.n...
IT
svnadmin at nemerle.org
Wed Oct 18 02:26:42 CEST 2006
Log:
Nested quotation handling.
Author: IT
Date: Wed Oct 18 02:26:40 2006
New Revision: 6764
Modified:
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanLexer.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanState.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanTokenInfo.n
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanLexer.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanLexer.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanLexer.n Wed Oct 18 02:26:40 2006
@@ -33,6 +33,7 @@
_onPreprocessor = false;
_tokenInfo.Token = null;
_bracketCount = -1;
+ _quotationCount = -1;
_tokenInfo.IsEndOfLine = eol();
}
@@ -42,6 +43,7 @@
mutable _onPreprocessor : bool;
mutable _keepDollar : bool;
mutable _bracketCount : int;
+ mutable _quotationCount : int;
_tokenInfo : ScanTokenInfo = ScanTokenInfo();
@@ -377,12 +379,41 @@
| EndSquare /* ] */ => (TP.Operator, C.Operator, TR.MatchBraces)
| BeginQuote /* <[ */ =>
+ if (_tokenInfo.IsQuotation)
+ {
+ when (_quotationCount < 0)
+ _quotationCount = _tokenInfo.QuotationCount;
+
+ _quotationCount++;
+ _tokenInfo.QuotationCount = _quotationCount;
+ }
+ else
+ {
_tokenInfo.State |= ScanState.Quotation;
+ _tokenInfo.QuotationCount = 1;
+ _quotationCount = 1;
+ }
+
(TP.Operator, C.Quotation, TR.None)
| EndQuote /* ]> */ =>
+ when (_tokenInfo.IsQuotation)
+ {
+ when (_quotationCount < 0)
+ _quotationCount = _tokenInfo.QuotationCount;
+
+ _quotationCount--;
+ _tokenInfo.QuotationCount = _quotationCount;
+
+ unless (_quotationCount > 0)
+ {
_tokenInfo.State &= ~ScanState.Quotation;
+ _tokenInfo.QuotationCount = 0;
+ _quotationCount = 0;
+ }
+ }
+
(TP.Operator, C.Quotation, TR.None)
//| RoundGroup(LooseGroup(Operator(name))) when name == "$" =>
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanState.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanState.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanState.n Wed Oct 18 02:26:40 2006
@@ -3,7 +3,7 @@
namespace Nemerle.Completion2
{
[Flags]
- public enum ScanState
+ public enum ScanState : uint
{
| None = 0x00000000
| Comment = 0x00000001
@@ -12,5 +12,6 @@
| String = 0x00000010
| MultiLineString = 0x00000020
| BracketCounter = 0x0F000000
+ | QuotationCounter = 0xF0000000
}
}
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanTokenInfo.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanTokenInfo.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/ScanTokenInfo.n Wed Oct 18 02:26:40 2006
@@ -26,6 +26,18 @@
}
}
+ public QuotationCount : int
+ {
+ get { (State & ScanState.QuotationCounter) :> int >> 28 }
+ set
+ {
+ def val = if (value > 0xF) 0xF else value;
+
+ State &= ~ScanState.QuotationCounter;
+ State |= (val << 28) :> ScanState;
+ }
+ }
+
public IsQuotation : bool { get { State %&& ScanState.Quotation } }
public IsComment : bool { get { State %&& ScanState.Comment } }
public IsString : bool { get { State %&& ScanState.String } }
More information about the svn
mailing list