コード例 #1
0
        private bool TryCompileCodePointToken(MessageScriptParser.TokenContext context, out CodePointToken codePointToken)
        {
            LogContextInfo(context);

            codePointToken = new CodePointToken();

            if (!TryGetFatal(context, context.IntLiteral, "Expected code point surrogate pair", out var argumentNodes))
            {
                return(false);
            }

            if (!TryParseByteIntLiteral(context, "Expected code point high surrogate", () => argumentNodes[0], out var highSurrogate))
            {
                return(false);
            }

            if (!TryParseByteIntLiteral(context, "Expected code point low surrogate", () => argumentNodes[1], out var lowSurrogate))
            {
                return(false);
            }

            codePointToken = new CodePointToken(highSurrogate, lowSurrogate);

            return(true);
        }
コード例 #2
0
        static void WriteCodePointToken(CodePointToken token)
        {
            string str = null;

            if (Encoding != null)
            {
                str = Encoding.GetString(new[] { token.HighSurrogate, token.LowSurrogate });

                // check if it's a glyph with no equivalent
                if (str == "\0")
                {
                    str = null;
                }
            }

            if (str == null)
            {
                str = $"[{token.HighSurrogate:X2} {token.LowSurrogate:X2}]";
            }

            Writer.Write(str);
        }
コード例 #3
0
 private void ProcessCodePoint(CodePointToken token, List <byte> bytes)
 {
     bytes.Add(token.HighSurrogate);
     bytes.Add(token.LowSurrogate);
 }
コード例 #4
0
 public void Decompile(CodePointToken token)
 {
     WriteTag($"x 0x{token.HighSurrogate:X2} 0x{token.LowSurrogate:X2}");
 }