///////////////////////////////////////////////////////////////////////////// public string GetMacroName( IInput input, out TokenMap tm ) { // ****** RecognizedCharType charType = Next( input, out tm ); // ****** if( RecognizedCharType.TokenStart == charType ) { Skip( input, tm ); return tm.Token; } // ****** return string.Empty; }
///////////////////////////////////////////////////////////////////////////// public string GetText( IInput input, TokenMap tm ) { // ****** // // offset index + length spans the entire match // string text = input.Next( tm.MatchLength ); return text; }
///////////////////////////////////////////////////////////////////////////// public virtual RecognizedCharType Next( IInput input, out TokenMap tm ) { /* powershell support for a leaing $ presumes that Next() is only called by NmpScanner and that IsMacroIdentifierStartChar() and IsValidMacroIdentifier() are never called to validate a powershell name - because they will not be validated THIS IS PROBABLY INVALID */ // ****** RecognizedCharType rct = TestCharType( input ); // // must tread tokens that start with '$' special - should do this check for // alt token starts as well but since we're going to disallow alt token starts // for macros as we rebuild this thing we'll ignore that // if( RecognizedCharType.TokenStartChar == rct && (SC.DOLLAR == input.Peek() || SC.HASH == input.Peek()) && ! IsValidInnerTokenChar(input.Peek(1)) ) { // // a token that starts with a $ can ONLY be followed by a '.' or a valid token // if( SC.DOT != input.Peek(1) ) { tm = null; return RecognizedCharType.JustAChar; } } // ****** if( RecognizedCharType.TokenStartChar == rct || RecognizedCharType.AltTokenStartChar == rct ) { tm = new TokenMap(); // ****** if( RecognizedCharType.AltTokenStartChar == rct ) { // // skip "(#" to find token // tm.Token = PeekToken( input, altTokenStart.CountChars ); tm.MatchLength = altTokenStart.CountChars + tm.Token.Length; tm.IsAltTokenFormat = true; } else { tm.Token = PeekToken( input, 0 ); tm.MatchLength = tm.Token.Length; tm.IsAltTokenFormat = false; } // ****** return RecognizedCharType.TokenStart; } // ****** tm = null; return rct; }
///////////////////////////////////////////////////////////////////////////// public void Skip( IInput input, TokenMap tm ) { // ****** int skipCount = tm.MatchLength; input.Skip( skipCount ); }