Exemplo n.º 1
0
        private OpResult ValidateTypeName(string type, Position pos, ParsingIndex index)
        {
            if (!ParsingHelper.IsNameValid(type))
            {
                return(OpResult.Fail($"Type `{type}` has invalid name"));
            }

            if (ParsingHelper.Primitives.Contains(type))
            {
                return(OpResult.Fail($"Try to redefine built-in type `{type}` at {pos}"));
            }

            if (_externStructs.ContainsKey(type))
            {
                return(OpResult.Fail($"Try to redefine extern struct `{type}` at {pos}"));
            }

            if (index.ContainsCompletedType(type))
            {
                return(OpResult.Fail($"Try to define type `{type}` second time at {pos}"));
            }

            return(OpResult.Ok());
        }
Exemplo n.º 2
0
 private bool IsTypeKnown(string itemType, ParsingIndex index)
 {
     return(ParsingHelper.Primitives.Contains(itemType) ||
            _externStructs.ContainsKey(itemType) ||
            index.ContainsCompletedType(itemType));
 }