コード例 #1
0
ファイル: Parser.cs プロジェクト: pipe01/LICC
        private Lexeme Take(LexemeKind lexemeKind, string expected = null, bool ignoreWhitespace = true)
        {
            if (ignoreWhitespace)
            {
                SkipWhitespaces();
            }

            if (Current.Kind != lexemeKind)
            {
                var lexemeChar = lexemeKind.GetCharacter();
                Error($"expected {expected ?? lexemeKind.ToString()}{(lexemeChar != null ? $" '{lexemeChar}'" : "")}, found '{Current.Content}' ({Current.Kind})");
            }

            return(TakeAny());
        }
コード例 #2
0
ファイル: LexemeKind.cs プロジェクト: pipe01/LICC
 public static string GetCharacter(this LexemeKind kind)
 {
     return(CharCache.TryGetValue(kind, out var c)
         ? c
         : CharCache[kind] = typeof(LexemeKind).GetField(kind.ToString()).GetCustomAttribute <DescriptionAttribute>()?.Description);
 }