Пример #1
0
        internal IDisposable RegisterStruct(LexerNode lexer, StructNode node)
        {
            if (!CanRegisterGlobalFunction())
            {
                throw new SemanticException($"Unavailable struct declaration '{lexer.Value}' inside another function '{currentRegistration.Name}'");
            }
            var str = new StructGloalObject {
                Name = lexer, Node = node
            };

            global.Add(lexer.Value, str);
            currentRegistration = new ScopeRegistration(lexer.Value, str);
            return(currentRegistration);
        }
Пример #2
0
        internal IDisposable RegisterFunction(LexerNode lexer, FunctionDeclarationNode node)
        {
            if (!CanRegisterGlobalFunction())
            {
                throw new SemanticException($"Unavailable function declaration '{lexer.Value}' inside another function '{currentRegistration.Name}'");
            }
            var f = new FuncGloalObject {
                Name = lexer, Node = node
            };

            global.Add(lexer.Value, f);
            scopes.Add(lexer.Value, f);

            currentRegistration = new ScopeRegistration(lexer.Value, f);
            return(currentRegistration);
        }
Пример #3
0
 public SemanticAnalyzer()
 {
     currentRegistration = new EmptyRegistration();
 }