⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sdbms_sql.v

📁 使用yacc的一个例子
💻 V
📖 第 1 页 / 共 5 页
字号:
    0  $accept : sqls $end

    1  sqls : sqls ';' sql
    2       | sql

    3  sql : connect_database
    4      | create_database
    5      | drop_database
    6      | create_user
    7      | drop_user
    8      | create_role
    9      | drop_role
   10      | set_parent_role
   11      | set_child_role
   12      | set_top_role
   13      | add_user_to_role
   14      | del_user_from_role
   15      | change_role
   16      | grant1
   17      | revoke1
   18      | grant2
   19      | revoke2
   20      | set_user_seclevel
   21      | set_table_seclevel
   22      | set_allow_seclevel
   23      | set_current_seclevel
   24      | create_table
   25      | drop_table
   26      | insert
   27      | update
   28      | delete
   29      | select
   30      | audit1
   31      | noaudit1
   32      | audit2
   33      | noaudit2
   34      | audit3
   35      | noaudit3
   36      |

   37  connect_database : CONNECT username WITH PASSWORD password
   38                   | CONNECT username TO dbname WITH PASSWORD password

   39  create_database : CREATE DATABASE dbname

   40  drop_database : DROP DATABASE dbname

   41  dbname : IDENTIFIER

   42  create_user : CREATE USER username WITH PASSWORD password
   43              | CREATE USER username WITH PASSWORD password WITH SECLEVEL class
   44              | CREATE USER username WITH PASSWORD password WITH SECLEVEL seclevel

   45  drop_user : DROP USER usernames

   46  username : IDENTIFIER

   47  usernames : usernames ',' username
   48            | username

   49  password : STRING

   50  create_role : CREATE ROLE rolename
   51              | CREATE ROLE rolename AS CHILD OF rolename
   52              | CREATE ROLE rolename AS PARENT OF rolenames

   53  drop_role : DROP ROLE rolenames

   54  rolename : IDENTIFIER

   55  rolenames : rolenames ',' rolename
   56            | rolename

   57  set_parent_role : SET PARENT ROLE rolename OF rolenames

   58  set_child_role : SET CHILD ROLE rolenames OF rolename

   59  set_top_role : SET TOP ROLE rolenames

   60  add_user_to_role : ADD USER usernames TO rolenames

   61  del_user_from_role : DEL USER usernames FROM rolenames

   62  change_role : CHANGE USER usernames TO rolenames

   63  grant1 : GRANT systemrights TO rolenames

   64  revoke1 : REVOKE systemrights FROM rolenames

   65  systemrights : systemrights ',' systemright
   66               | systemright

   67  systemright : CREATE DATABASE
   68              | CREATE TABLE
   69              | CREATE VIEW
   70              | CREATE INDEX
   71              | DROP DATABASE
   72              | DROP TABLE
   73              | DROP VIEW
   74              | DROP INDEX
   75              | GRANT
   76              | REVOKE

   77  grant2 : GRANT operations where_clause ON tablename TO rolenames
   78         | GRANT operations where_clause ON tablename TO rolenames WITH GRANT OPTION

   79  revoke2 : REVOKE operations where_clause ON tablename FROM rolenames
   80          | REVOKE operations where_clause ON tablename FROM rolenames CASCADE
   81          | REVOKE operations where_clause ON tablename FROM rolenames RESTRICT
   82          | REVOKE GRANT OPTION FOR operations where_clause FROM tablename TO rolenames

   83  operations : operations ',' operation
   84             | operation

   85  operation : SELECT
   86            | SELECT '(' fieldnames ')'
   87            | INSERT
   88            | INSERT '(' fieldnames ')'
   89            | UPDATE
   90            | UPDATE '(' fieldnames ')'
   91            | YDELETE
   92            | YDELETE '(' fieldnames ')'

   93  seclevel : OPLESS OPMORE
   94           | OPLESS ',' OPMORE
   95           | OPLESS class ',' OPMORE
   96           | OPLESS ',' range OPMORE
   97           | OPLESS class ',' range OPMORE

   98  class : INTEGER

   99  range : '{' '}'
  100        | '{' rangeitems '}'
  101        | '{' rangeitems error

  102  rangeitems : rangeitems ',' rangeitem
  103             | rangeitem

  104  rangeitem : STRING

  105  set_user_seclevel : SET SECURITY LEVEL class TO usernames
  106                    | SET SECURITY LEVEL seclevel TO usernames

  107  set_allow_seclevel : SET ALLOW SECURITY LEVEL seclevel ON tablenames TO usernames

  108  set_current_seclevel : SET CURRENT SECURITY LEVEL seclevel ON tablenames TO usernames

  109  set_table_seclevel : SET SECURITY LEVEL seclevel ON tablenames

  110  tablename : IDENTIFIER

  111  tablenames : tablenames ',' tablename
  112             | tablename

  113  fieldname : IDENTIFIER

  114  fieldnames : fieldnames ',' fieldname
  115             | fieldname

  116  create_table : CREATE TABLE tablename tabcollist
  117               | CREATE TABLE tablename tabcollist WITH SECLEVEL seclevel

  118  tabcollist : '(' tabcols ')'
  119             | '(' tabcols error

  120  tabcols : tabcols ',' tabcol
  121          | tabcol

  122  tabcol : coldef
  123         | keydef

  124  coldef : fieldname datatype
  125         | fieldname datatype OPNOT YNULL

  126  datatype : char_type
  127           | int_type
  128           | bool_type

  129  char_type : CHAR '(' INTEGER ')'

  130  int_type : INT

  131  bool_type : BOOL

  132  keydef : PRIMARY KEY keycollist

  133  keycollist : '(' keycols ')'
  134             | '(' keycols error

  135  keycols : keycols ',' fieldname
  136          | fieldname

  137  drop_table : DROP TABLE tablenames

  138  insert : INSERT INTO tablename insert_collist VALUES insert_vallist
  139         | INSERT INTO tablename VALUES insert_vallist

  140  insert_collist : '(' fieldnames ')'

  141  insert_vallist : '(' vallist ')'

  142  vallist : vallist ',' value
  143          | value

  144  value : expr
  145        | expr '(' seclevel ')'

  146  expr : expr OPADD term
  147       | expr OPSUB term
  148       | term

  149  term : term OPMUL factor
  150       | term OPDIV factor
  151       | factor

  152  factor : '(' expr ')'
  153         | '(' expr error
  154         | OPSUB factor
  155         | INTEGER
  156         | STRING
  157         | bool_value
  158         | seclevel
  159         | colref

  160  bool_value : YTRUE
  161             | YFALSE

  162  colref : fieldname
  163         | SECLEVEL '(' fieldname ')'
  164         | tablename '.' fieldname
  165         | SECLEVEL '(' tablename '.' fieldname ')'

  166  update : UPDATE tablename SET set_list
  167         | UPDATE tablename SET set_list WHERE conditions

  168  set_list : set_list ',' set_clause
  169           | set_clause

  170  set_clause : fieldname OPEQU value

  171  conditions : conditions OPOR condition
  172             | condition

  173  condition : condition OPAND condfactor
  174            | condfactor

  175  condfactor : '(' conditions ')'
  176             | OPNOT condfactor
  177             | comp_clause

  178  comp_clause : expr OPEQU expr
  179              | expr OPUNEQU expr
  180              | expr OPLESS expr
  181              | expr OPLESSEQU expr
  182              | expr OPMORE expr
  183              | expr OPMOREEQU expr

  184  delete : YDELETE FROM tablename
  185         | YDELETE FROM tablename WHERE conditions

  186  select : SELECT select_list FROM tablenames where_clause order_clause believe_clause

  187  select_list : OPMUL
  188              | select_sub_list

  189  select_sub_list : select_sub_list ',' expr
  190                  | expr

  191  where_clause : WHERE conditions
  192               |

  193  order_clause : ORDER BY order_list
  194               |

  195  order_list : order_list ',' order_item
  196             | order_item

  197  order_item : fieldname
  198             | fieldname ASC
  199             | fieldname DESC

  200  believe_clause : BELIEVED BY SELF
  201                 | BELIEVED BY seclevel
  202                 |

  203  audit1 : AUDIT executor

  204  noaudit1 : NOAUDIT executor

  205  executor : USER '(' usernames ')'
  206           | ROLE '(' rolenames ')'
  207           | USER '(' usernames ')' ',' ROLE '(' rolenames ')'
  208           | ROLE '(' rolenames ')' ',' USER '(' usernames ')'

  209  audit2 : AUDIT objectrights ON tablename EXECUTED BY executor

  210  noaudit2 : NOAUDIT objectrights ON tablename EXECUTED BY executor

  211  objectrights : objectrights ',' objectright
  212               | objectright

  213  objectright : SELECT
  214              | INSERT
  215              | UPDATE
  216              | YDELETE

  217  audit3 : AUDIT auditrights EXECUTED BY executor

  218  noaudit3 : NOAUDIT auditrights EXECUTED BY executor

  219  auditrights : auditrights ',' auditright
  220              | auditright

  221  auditright : systemright
  222             | security_right

  223  security_right : CREATE USER
  224                 | DROP USER
  225                 | CREATE ROLE
  226                 | DROP ROLE
  227                 | SET PARENT ROLE
  228                 | SET CHILD ROLE
  229                 | SET TOP ROLE
  230                 | ADD ROLE
  231                 | DEL ROLE
  232                 | CHANGE ROLE
  233                 | SET USER SECURITY LEVEL
  234                 | SET USER ALLOW SECURITY LEVEL
  235                 | SET USER CURRENT SECURITY LEVEL
  236                 | SET TABLE SECURITY LEVEL
  237                 | GRANT OBJRIGHT
  238                 | REVOKE OBJRIGHT
  239                 | GRANT SYSRIGHT
  240                 | REVOKE SYSRIGHT
  241                 | AUDIT USER
  242                 | NOAUDIT USER
  243                 | AUDIT OBJRIGHT
  244                 | NOAUDIT OBJRIGHT
  245                 | AUDIT SYSRIGHT
  246                 | NOAUDIT SYSRIGHT


state 0
	$accept : . sqls $end
	sql : .  (36)

	CONNECT  shift 1
	CREATE  shift 2
	DROP  shift 3
	ADD  shift 4
	DEL  shift 5
	CHANGE  shift 6
	GRANT  shift 7
	REVOKE  shift 8
	SET  shift 9
	AUDIT  shift 10
	NOAUDIT  shift 11
	SELECT  shift 12
	INSERT  shift 13
	UPDATE  shift 14
	YDELETE  shift 15
	.  reduce 36

	sqls goto 16
	sql goto 17
	connect_database goto 18
	create_database goto 19
	drop_database goto 20
	create_user goto 21
	drop_user goto 22
	create_role goto 23
	drop_role goto 24
	set_parent_role goto 25
	set_child_role goto 26
	set_top_role goto 27
	add_user_to_role goto 28
	del_user_from_role goto 29
	change_role goto 30
	grant1 goto 31
	revoke1 goto 32
	grant2 goto 33
	revoke2 goto 34
	set_user_seclevel goto 35
	set_table_seclevel goto 36
	set_allow_seclevel goto 37
	set_current_seclevel goto 38
	create_table goto 39
	drop_table goto 40
	insert goto 41
	update goto 42
	delete goto 43
	select goto 44
	audit1 goto 45
	noaudit1 goto 46
	audit2 goto 47
	noaudit2 goto 48
	audit3 goto 49
	noaudit3 goto 50


state 1
	connect_database : CONNECT . username WITH PASSWORD password
	connect_database : CONNECT . username TO dbname WITH PASSWORD password

	IDENTIFIER  shift 51

	username goto 52


state 2
	create_database : CREATE . DATABASE dbname
	create_user : CREATE . USER username WITH PASSWORD password
	create_user : CREATE . USER username WITH PASSWORD password WITH SECLEVEL class
	create_user : CREATE . USER username WITH PASSWORD password WITH SECLEVEL seclevel
	create_role : CREATE . ROLE rolename
	create_role : CREATE . ROLE rolename AS CHILD OF rolename
	create_role : CREATE . ROLE rolename AS PARENT OF rolenames
	create_table : CREATE . TABLE tablename tabcollist
	create_table : CREATE . TABLE tablename tabcollist WITH SECLEVEL seclevel

	ROLE  shift 53
	DATABASE  shift 54
	TABLE  shift 55
	USER  shift 56


state 3
	drop_database : DROP . DATABASE dbname
	drop_user : DROP . USER usernames
	drop_role : DROP . ROLE rolenames
	drop_table : DROP . TABLE tablenames

	ROLE  shift 57
	DATABASE  shift 58
	TABLE  shift 59
	USER  shift 60


state 4
	add_user_to_role : ADD . USER usernames TO rolenames

	USER  shift 61


state 5
	del_user_from_role : DEL . USER usernames FROM rolenames

	USER  shift 62


state 6
	change_role : CHANGE . USER usernames TO rolenames

	USER  shift 63


state 7
	grant1 : GRANT . systemrights TO rolenames
	grant2 : GRANT . operations where_clause ON tablename TO rolenames
	grant2 : GRANT . operations where_clause ON tablename TO rolenames WITH GRANT OPTION

	CREATE  shift 64
	DROP  shift 65
	GRANT  shift 66
	REVOKE  shift 67
	SELECT  shift 68
	INSERT  shift 69
	UPDATE  shift 70
	YDELETE  shift 71

	systemright goto 72
	systemrights goto 73
	operations goto 74
	operation goto 75


state 8
	revoke1 : REVOKE . systemrights FROM rolenames
	revoke2 : REVOKE . operations where_clause ON tablename FROM rolenames
	revoke2 : REVOKE . operations where_clause ON tablename FROM rolenames CASCADE
	revoke2 : REVOKE . operations where_clause ON tablename FROM rolenames RESTRICT
	revoke2 : REVOKE . GRANT OPTION FOR operations where_clause FROM tablename TO rolenames

	CREATE  shift 64
	DROP  shift 65
	GRANT  shift 76
	REVOKE  shift 67
	SELECT  shift 68
	INSERT  shift 69
	UPDATE  shift 70
	YDELETE  shift 71

	systemright goto 72
	systemrights goto 77
	operations goto 78
	operation goto 75


state 9
	set_parent_role : SET . PARENT ROLE rolename OF rolenames
	set_child_role : SET . CHILD ROLE rolenames OF rolename
	set_top_role : SET . TOP ROLE rolenames
	set_user_seclevel : SET . SECURITY LEVEL class TO usernames
	set_user_seclevel : SET . SECURITY LEVEL seclevel TO usernames
	set_allow_seclevel : SET . ALLOW SECURITY LEVEL seclevel ON tablenames TO usernames
	set_current_seclevel : SET . CURRENT SECURITY LEVEL seclevel ON tablenames TO usernames
	set_table_seclevel : SET . SECURITY LEVEL seclevel ON tablenames

	CHILD  shift 79
	PARENT  shift 80
	TOP  shift 81
	SECURITY  shift 82
	ALLOW  shift 83
	CURRENT  shift 84


state 10
	audit1 : AUDIT . executor
	audit2 : AUDIT . objectrights ON tablename EXECUTED BY executor
	audit3 : AUDIT . auditrights EXECUTED BY executor

	CREATE  shift 85
	DROP  shift 86
	ADD  shift 87
	DEL  shift 88
	CHANGE  shift 89
	ROLE  shift 90
	GRANT  shift 91
	REVOKE  shift 92
	SET  shift 93
	AUDIT  shift 94
	NOAUDIT  shift 95
	SELECT  shift 96
	INSERT  shift 97
	UPDATE  shift 98
	YDELETE  shift 99
	USER  shift 100

	objectright goto 101
	objectrights goto 102
	systemright goto 103
	auditright goto 104
	security_right goto 105
	executor goto 106
	auditrights goto 107


state 11
	noaudit1 : NOAUDIT . executor
	noaudit2 : NOAUDIT . objectrights ON tablename EXECUTED BY executor
	noaudit3 : NOAUDIT . auditrights EXECUTED BY executor

	CREATE  shift 85
	DROP  shift 86
	ADD  shift 87
	DEL  shift 88
	CHANGE  shift 89
	ROLE  shift 90
	GRANT  shift 91
	REVOKE  shift 92
	SET  shift 93
	AUDIT  shift 94
	NOAUDIT  shift 95
	SELECT  shift 96
	INSERT  shift 97
	UPDATE  shift 98
	YDELETE  shift 99
	USER  shift 100

	objectright goto 101
	objectrights goto 108
	systemright goto 103
	auditright goto 104
	security_right goto 105
	executor goto 109
	auditrights goto 110


state 12
	select : SELECT . select_list FROM tablenames where_clause order_clause believe_clause

	'('  shift 111
	SECLEVEL  shift 112
	OPSUB  shift 113
	OPMUL  shift 114
	OPLESS  shift 115
	YTRUE  shift 116
	YFALSE  shift 117
	IDENTIFIER  shift 118
	STRING  shift 119
	INTEGER  shift 120

	tablename goto 121
	fieldname goto 122
	seclevel goto 123
	expr goto 124
	term goto 125
	factor goto 126
	colref goto 127
	bool_value goto 128
	select_list goto 129
	select_sub_list goto 130


state 13
	insert : INSERT . INTO tablename insert_collist VALUES insert_vallist
	insert : INSERT . INTO tablename VALUES insert_vallist

	INTO  shift 131


state 14
	update : UPDATE . tablename SET set_list
	update : UPDATE . tablename SET set_list WHERE conditions

	IDENTIFIER  shift 132

	tablename goto 133


state 15
	delete : YDELETE . FROM tablename
	delete : YDELETE . FROM tablename WHERE conditions

	FROM  shift 134


state 16
	$accept : sqls . $end  (0)
	sqls : sqls . ';' sql

	$end  accept
	';'  shift 135


state 17
	sqls : sql .  (2)

	.  reduce 2


state 18
	sql : connect_database .  (3)

	.  reduce 3


state 19
	sql : create_database .  (4)

	.  reduce 4


state 20
	sql : drop_database .  (5)

	.  reduce 5


state 21
	sql : create_user .  (6)

	.  reduce 6


state 22
	sql : drop_user .  (7)

	.  reduce 7


state 23
	sql : create_role .  (8)

	.  reduce 8


state 24
	sql : drop_role .  (9)

	.  reduce 9


state 25
	sql : set_parent_role .  (10)

	.  reduce 10


state 26
	sql : set_child_role .  (11)

	.  reduce 11


state 27
	sql : set_top_role .  (12)

	.  reduce 12


state 28
	sql : add_user_to_role .  (13)

	.  reduce 13


state 29
	sql : del_user_from_role .  (14)

	.  reduce 14


state 30
	sql : change_role .  (15)

	.  reduce 15


state 31
	sql : grant1 .  (16)

	.  reduce 16


state 32
	sql : revoke1 .  (17)

	.  reduce 17


state 33
	sql : grant2 .  (18)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -