示例#1
0
        void InterpretGlobal(CleanupAstNodeStates cleanStates)
        {
            for (var advancePosition = 0; advancePosition < cleanStates.Count; advancePosition++)
            {
                var currentNode = cleanStates[advancePosition];
                var tokenKind = currentNode.GetTokenKind();
                switch (tokenKind)
                {
                    case TokenKind.TypeName:
                        var isVariableDeclaration = CheckIfTypeDefinesVariable(advancePosition,
                                                                               cleanStates.MappedNodes);
                        if (isVariableDeclaration)
                            cleanStates.ShiftVariableDeclaration(advancePosition);
                        else
                        {
                            cleanStates.ShiftFunctionDeclaration(advancePosition);
                            var blockStates = cleanStates[advancePosition].States[3].States;
                            InterpretBlock(blockStates);
                        }

                        break;
                    case TokenKind.SharpDefine:
                        cleanStates.ShiftSharpDefineDeclaration(advancePosition);
                        break;

                    case TokenKind.SharpImport:
                        cleanStates.ShiftSharpImports(advancePosition);
                        break;
                    case TokenKind.SharpProperty:
                        break;
                    case TokenKind.Static:
                        ShiftStaticDefinition(cleanStates, advancePosition);
                        break;
                    case TokenKind.Extern:
                        ShiftExternDefinition(cleanStates, advancePosition);

                        break;

                    case TokenKind.Input:
                        cleanStates.ShiftInputs(advancePosition);
                        break;
                    default:
                        throw new InvalidDataException("Input type not handled");
                }
            }
        }