Esempio n. 1
0
        protected void UnescapeSymbolValue()
        {
            Debug.Assert(CharSource[_startPosition] == '@' && CharSource[_startPosition + 1] == '@');
            if (SkipValueParsing)
            {
                return;
            }

            _value = _s;
            UString original = CharSource.Slice(_startPosition + 2, InputPosition - _startPosition - 2);

            if (_hasEscapes)
            {
                _textValue = Les3Lexer.UnescapeQuotedString(ref original, Error);
                Debug.Assert(original.IsEmpty);
            }
            else if (original[0, '\0'] == '`')
            {
                _textValue = original.Substring(1, original.Length - 2);
            }
            else
            {
                _textValue = original;
            }
        }
Esempio n. 2
0
 protected UString UnescapeString(bool isTripleQuoted, bool allowExtraIndent = false)
 {
     if (SkipValueParsing)
     {
         return("");
     }
     if (_hasEscapes)
     {
         UString original = CharSource.Slice(_startPosition, InputPosition - _startPosition);
         _textValue = Les3Lexer.UnescapeQuotedString(ref original, Error, IndentString, allowExtraIndent);
         Debug.Assert(original.IsEmpty);
     }
     else
     {
         Debug.Assert(CharSource.TryGet(InputPosition - 1, '?') == CharSource.TryGet(_startPosition, '!'));
         if (isTripleQuoted)
         {
             _textValue = CharSource.Slice(_startPosition + 3, InputPosition - _startPosition - 6).ToString();
         }
         else
         {
             _textValue = CharSource.Slice(_startPosition + 1, InputPosition - _startPosition - 2).ToString();
         }
     }
     return(_textValue);
 }
Esempio n. 3
0
        // After the generated lexer code determines the boundaries of the token,
        // one of these methods extracts the value of the token (e.g. "17L" => (long)17)
        // There are value parsers for identifiers, numbers, and strings; certain
        // parser cores are also accessible as public static methods.

        #region String unescaping (including public UnescapeQuotedString())

        protected void UnescapeSQStringValue()
        {
            _value = _c;
            var text = Text();

            if (!_hasEscapes)
            {
                _textValue = text.Slice(1, text.Length - 2);
            }
            else
            {
                _textValue = Les3Lexer.UnescapeQuotedString(ref text, Error);
            }
        }
Esempio n. 4
0
        protected internal static object ParseSQStringValue(UString text, Action <int, string> Error)
        {
            var sb = TempSB();

            Les3Lexer.UnescapeQuotedString(ref text, Error, sb, "\t");
            Debug.Assert(text.IsEmpty);
            if (sb.Length == 1)
            {
                return(CG.Cache(sb[0]));
            }
            else
            {
                if (sb.Length == 0)
                {
                    Error(0, Localize.Localized("Empty character literal"));
                }
                else
                {
                    Error(0, Localize.Localized("Character literal has {0} characters (there should be exactly one)", sb.Length));
                }
                return(sb.ToString());
            }
        }
Esempio n. 5
0
 public static void UnescapeQuotedString(ref UString sourceText, Action <int, string> onError, StringBuilder sb, UString indentation = default(UString), bool les3TQIndents = false)
 => Les3Lexer.UnescapeQuotedString(ref sourceText, onError, sb, indentation, les3TQIndents);