avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From froehl...@apache.org
Subject cvs commit: jakarta-avalon-cornerstone/apps/db/src/sql/javacc BasicSQLParser.jj
Date Wed, 28 Nov 2001 15:25:37 GMT
froehlich    01/11/28 07:25:37

  Added:       apps/db/src/sql/javacc BasicSQLParser.jj
  Log:
  no message
  
  Revision  Changes    Path
  1.1                  jakarta-avalon-cornerstone/apps/db/src/sql/javacc/BasicSQLParser.jj
  
  Index: BasicSQLParser.jj
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  
  PARSER_BEGIN(BasicSQLParser)
  package org.apache.avalon.db.basic.parser;
  
  import org.apache.avalon.db.server.AbstractSQLParser;
  
  /**
   * Class BasicSQLParser
   *
   * @author Gerhard Froehlich <a href="mailto:g-froehlich@gmx.de">g-froehlich@gmx.de</a>
   */
  public class BasicSQLParser extends AbstractSQLParser {
      public static void main(String args[]) {
          BasicSQLParser parser = new BasicSQLParser(System.in);
          parser.Test((String)args[0]);
      }
  }
  
  PARSER_END(BasicSQLParser)
  
  SKIP:
  {
      " "
      | "\n"
      | "\r"
      | "\t"
  }
  
  SKIP:
  {
      <COMMENT_LINE: "--" (~["\n","\r"])* ("\n"|"\r"|"\r\n") >
  }
  
  
  SKIP:
  {
      <COMMENT_BLOCK: "/*" (~["*"])* "*" ("*" | (~["*","/"] (~["*"])* "*"))* "/">
  }
  
  TOKEN [IGNORE_CASE] : { /* Datatypes */
      <VARCHAR:       "varchar">
      | <TIMESTAMP:   "timestamp">
      | <TIME:        "time">
      | <SMALLINT:    "smallint">
      | <REAL:        "real">
      | <INTEGER:     "integer">
      | <DECIMAL:     "decimal">
      | <DATE:        "date">
      | <BIGINT:      "bigint">
  }
  
  TOKEN [IGNORE_CASE] : { /* Actions */
      <UPDATE:        "update">
      | <SELECT:      "select">
      | <ROLLBACK:    "rollback">
      | <INSERT:      "insert">
      | <GRANT:       "grant">
      | <DROP:        "drop">
      | <DELETE:      "delete">
      | <CREATE:      "create">
      | <COMMIT:      "commit">
      | <ALTER:       "alter">
  }
  
  TOKEN [IGNORE_CASE] : { /* Keywords */
      <AS:          "as">
      | <SET:         "set">
      | <ASC:         "asc">
      | <FROM:        "from">
      | <DESC:        "desc">
      | <INTO:        "into">
      | <VIEW:        "view">
      | <COUNT:       "count">
      | <WHERE:       "where">
      | <TABLE:       "table">
      | <INDEX:       "index">
      | <VALUES:      "values">
      | <HAVING:      "having">
      | <BETWEEN:     "between">
      | <GROUPBY:     "group by">
      | <ORDERBY:     "order by">
      | <DISTINCT:    "distinct">
  }
  
  TOKEN [IGNORE_CASE] : { /* Operators */
      <EQUAL:                 "=" >
      | <GREATERTHAN:         ">" >
      | <SMALLERTHAN:         "<" >
      | <GREATERTHANOREQUAL:  ">=" >
      | <SMALLERTHANOREQUAL:  "<=" >
      | <LIKE:                "like" >
  }
  
  /**
   * Test Method for command line input
   */
  void Test(String sql) :
  { }
  {
      ( 
          parseSQLString(sql) 
      ) ";"
  }
  
  void parseSQLString(String sql) :
  { }
  {
      ( 
          Update(sql)
          | Select(sql)
          | Rollback(sql)
          | Insert(sql)
          | Grant(sql)
          | Drop(sql)
          | Delete(sql)
          | Commit(sql)
          | Alter(sql)
      ) ";"
  }
  
  void Select(String sql) :
  { }
  {
      <SELECT>
          {
              //Implementation
          }
  
      <FROM>
          {
              //Implementation
          }
      //[ Where() ] //process where
  }
  
  void Update(String sql) :
  {}
  {
      <EOF>   
  }
  
  void Rollback(String sql) :
  {}
  {
      <EOF>   
  }
  
  void Insert(String sql) :
  {}
  {
      <EOF>   
  }
  
  void Grant(String sql) :
  {}
  {
      <EOF>   
  }
  
  void Drop(String sql) :
  {}
  {
      <EOF>   
  }
  
  void Delete(String sql) :
  {}
  {
      <EOF>   
  }
  
  void Commit(String sql) :
  {}
  {
      <EOF>   
  }
  
  void Alter(String sql) :
  {}
  {
      <EOF>   
  }
  
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message