예제 #1
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();
        }
예제 #2
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);
        }
예제 #3
0
 private void SetPackageName(ParseCursor cursor, ModuleNode result)
 {
     cursor.Advance();
     result.Name = cursor.AdvanceToken().Text;
     cursor.Advance(TokenKind.Eoln);
 }