Exemplo n.º 1
0
        public ColumnIndexOutOfBoundsException(TextualDatabase database, TextualTable table, int index)
        {
            TextualDatabase = database;
            TextualTable    = table;

            message = string.Format(MESSAGE_FORMAT, table.Name, index);
        }
        public ColumnAlreadyExistsException(TextualDatabase database, TextualTable table, string column)
        {
            TextualDatabase = database;
            TextualTable    = table;

            message = string.Format(MESSAGE_FORMAT, table.Name, column);
        }
Exemplo n.º 3
0
        private TextualTable parseTable(TextualDatabase db)
        {
            // name:
            string name = expectToken(TokenType.Identifier).Value;

            expectToken(TokenType.Colon);

            TextualTable table = new TextualTable(db, name);

            // | column1 | column2 | column3 |
            expectToken(TokenType.Pipe);
            while (!matchToken(TokenType.Dash))
            {
                table.Columns.Add(expectToken(TokenType.Identifier).Value);
                expectToken(TokenType.Pipe);
            }

            // -------------
            while (acceptToken(TokenType.Dash))
            {
                ;
            }

            // Rows
            while (!matchToken(TokenType.Question))
            {
                table.AddRow(parseRow(table));
            }

            // ?
            expectToken(TokenType.Question);

            return(table);
        }
        public RowNotFoundException(TextualDatabase database, TextualTable table, TextualRow row)
        {
            TextualDatabase = database;

            TextualTable = table;
            TextualRow   = row;

            message = string.Format(MESSAGE_FORMAT, table.Name);
        }
Exemplo n.º 5
0
        public TextualDatabase ParseDatabase(string name)
        {
            TextualDatabase db = new TextualDatabase(name);

            while (!endOfStream)
            {
                db.AddTable(parseTable(db));
            }

            return(db);
        }
Exemplo n.º 6
0
 public bool OpenDatabase(string file)
 {
     try
     {
         Database = TextualDatabase.Parse(file, File.ReadAllText(file));
     }
     catch (ComponentException ce)
     {
         throw ce;
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 7
0
        public static TextualTable ExecuteOperation(TextualDatabase database, string op)
        {
            var tokens = new Scanner(op).Scan();

            return(new OperationParser(database, tokens).Parse());
        }
Exemplo n.º 8
0
 public TextualDeleteTableOperation(TextualDatabase database)
 {
     this.database = database;
 }
Exemplo n.º 9
0
        public TableNotFoundException(TextualDatabase database, string tableName)
        {
            TextualDatabase = database;

            message = string.Format(MESSAGE_FORMAT, database.Name, tableName);
        }
Exemplo n.º 10
0
        public TableAlreadyExistsException(TextualDatabase database, string tableName)
        {
            TextualDatabase = database;

            message = string.Format(MESSAGE_FORMAT, tableName);
        }
Exemplo n.º 11
0
 public TextualCreateTableOperation(TextualDatabase database, string name)
 {
     Result = new TextualTable(database, name);
 }
Exemplo n.º 12
0
 public OperationParser(TextualDatabase database, List <Token> tokens)
 {
     this.database = database;
     this.tokens   = tokens;
     position      = 0;
 }