예제 #1
0
        private void ParseGlobalScope(ParseCursor cursor, ModuleNode result)
        {
            var currToken = cursor.Current;

            switch (currToken.Text)
            {
            case "package":
                SetPackageName(cursor, result);
                break;

            case "func":
                SetFunctionDeclaration(cursor, result);
                break;

            default:
                throw new InvalidDataException("Unexpected reserved word: " + currToken);
            }
        }
예제 #2
0
        public FunctionDeclaration(ParseCursor cursor)
        {
            if (cursor.Current.Kind == TokenKind.Identifier)
            {
                Name = cursor.Current.Text;
                cursor.Advance();
            }

            cursor.Advance("(");
            if (cursor.Current.Text == ")")
            {
                cursor.Advance();
            }
            if (cursor.Current.Text == "{")
            {
                return;
            }

            throw new System.NotImplementedException();
        }
예제 #3
0
        public ModuleNode ParseModule(Token[] tokens)
        {
            ParseCursor _cursor = new ParseCursor(tokens);

            var result = new ModuleNode();

            do
            {
                switch (_cursor.Current.Kind)
                {
                case TokenKind.Reserved:
                    ParseGlobalScope(_cursor, result);
                    continue;

                default:
                    throw new DataException("Unexpected token: " + _cursor.Current);
                }

                _cursor.Advance();
            } while (true);
            return(result);
        }
예제 #4
0
 private void SetPackageName(ParseCursor cursor, ModuleNode result)
 {
     cursor.Advance();
     result.Name = cursor.AdvanceToken().Text;
     cursor.Advance(TokenKind.Eoln);
 }
예제 #5
0
        private void SetFunctionDeclaration(ParseCursor cursor, ModuleNode result)
        {
            var functionDeclaration = new FunctionDeclaration(cursor.ReadRow());

            throw new System.NotImplementedException();
        }