| 1 | //;-*- mode: antlr -*- |
|---|
| 2 | /* |
|---|
| 3 | QueryJ |
|---|
| 4 | |
|---|
| 5 | Copyright (C) 2002-2007 Jose San Leandro Armendariz |
|---|
| 6 | chous@acm-sl.org |
|---|
| 7 | |
|---|
| 8 | This library is free software; you can redistribute it and/or |
|---|
| 9 | modify it under the terms of the GNU General Public |
|---|
| 10 | License as published by the Free Software Foundation; either |
|---|
| 11 | version 2 of the License, or any later version. |
|---|
| 12 | |
|---|
| 13 | This library is distributed in the hope that it will be useful, |
|---|
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 16 | General Public License for more details. |
|---|
| 17 | |
|---|
| 18 | You should have received a copy of the GNU General Public |
|---|
| 19 | License along with this library; if not, write to the Free Software |
|---|
| 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 21 | |
|---|
| 22 | Thanks to ACM S.L. for distributing this library under the GPL license. |
|---|
| 23 | Contact info: chous@acm-sl.org |
|---|
| 24 | Postal Address: c/Playa de Lagoa, 1 |
|---|
| 25 | Urb. Valdecabanas |
|---|
| 26 | Boadilla del monte |
|---|
| 27 | 28660 Madrid |
|---|
| 28 | Spain |
|---|
| 29 | |
|---|
| 30 | ****************************************************************************** |
|---|
| 31 | * |
|---|
| 32 | * $HeadURL$ |
|---|
| 33 | * |
|---|
| 34 | * Author: Jose San Leandro Armendariz |
|---|
| 35 | * |
|---|
| 36 | * Description: Defines the ANTLR parser rules for physical e/r comments. |
|---|
| 37 | * |
|---|
| 38 | */ |
|---|
| 39 | grammar PerComment; |
|---|
| 40 | |
|---|
| 41 | @parser::header |
|---|
| 42 | { |
|---|
| 43 | /* |
|---|
| 44 | QueryJ |
|---|
| 45 | |
|---|
| 46 | Copyright (C) 2002-2007 Jose San Leandro Armendariz |
|---|
| 47 | chous@acm-sl.org |
|---|
| 48 | |
|---|
| 49 | This library is free software; you can redistribute it and/or |
|---|
| 50 | modify it under the terms of the GNU General Public |
|---|
| 51 | License as published by the Free Software Foundation; either |
|---|
| 52 | version 2 of the License, or any later version. |
|---|
| 53 | |
|---|
| 54 | This library is distributed in the hope that it will be useful, |
|---|
| 55 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 56 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 57 | General Public License for more details. |
|---|
| 58 | |
|---|
| 59 | You should have received a copy of the GNU General Public |
|---|
| 60 | License along with this library; if not, write to the Free Software |
|---|
| 61 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 62 | |
|---|
| 63 | Thanks to ACM S.L. for distributing this library under the GPL license. |
|---|
| 64 | Contact info: chous@acm-sl.org |
|---|
| 65 | Postal Address: c/Playa de Lagoa, 1 |
|---|
| 66 | Urb. Valdecabanas |
|---|
| 67 | Boadilla del monte |
|---|
| 68 | 28660 Madrid |
|---|
| 69 | Spain |
|---|
| 70 | |
|---|
| 71 | ****************************************************************************** |
|---|
| 72 | * |
|---|
| 73 | * Generated from PerComment.g by ANTLR. |
|---|
| 74 | * |
|---|
| 75 | * Author: Jose San Leandro Armendariz |
|---|
| 76 | * |
|---|
| 77 | * Description: ANTLR parser for PerComment.g |
|---|
| 78 | * |
|---|
| 79 | */ |
|---|
| 80 | package org.acmsl.queryj.tools.antlr; |
|---|
| 81 | |
|---|
| 82 | /* |
|---|
| 83 | * Importing some JDK classes. |
|---|
| 84 | */ |
|---|
| 85 | import java.util.List; |
|---|
| 86 | } |
|---|
| 87 | |
|---|
| 88 | @lexer::header |
|---|
| 89 | { |
|---|
| 90 | /* |
|---|
| 91 | QueryJ |
|---|
| 92 | |
|---|
| 93 | Copyright (C) 2002-2007 Jose San Leandro Armendariz |
|---|
| 94 | chous@acm-sl.org |
|---|
| 95 | |
|---|
| 96 | This library is free software; you can redistribute it and/or |
|---|
| 97 | modify it under the terms of the GNU General Public |
|---|
| 98 | License as published by the Free Software Foundation; either |
|---|
| 99 | version 2 of the License, or any later version. |
|---|
| 100 | |
|---|
| 101 | This library is distributed in the hope that it will be useful, |
|---|
| 102 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 103 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 104 | General Public License for more details. |
|---|
| 105 | |
|---|
| 106 | You should have received a copy of the GNU General Public |
|---|
| 107 | License along with this library; if not, write to the Free Software |
|---|
| 108 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 109 | |
|---|
| 110 | Thanks to ACM S.L. for distributing this library under the GPL license. |
|---|
| 111 | Contact info: chous@acm-sl.org |
|---|
| 112 | Postal Address: c/Playa de Lagoa, 1 |
|---|
| 113 | Urb. Valdecabanas |
|---|
| 114 | Boadilla del monte |
|---|
| 115 | 28660 Madrid |
|---|
| 116 | Spain |
|---|
| 117 | |
|---|
| 118 | ****************************************************************************** |
|---|
| 119 | * |
|---|
| 120 | * Generated from PerComment.g by ANTLR. |
|---|
| 121 | * |
|---|
| 122 | * Author: Jose San Leandro Armendariz |
|---|
| 123 | * |
|---|
| 124 | * Description: ANTLR lexer for PerComment.g |
|---|
| 125 | * |
|---|
| 126 | */ |
|---|
| 127 | package org.acmsl.queryj.tools.antlr; |
|---|
| 128 | } |
|---|
| 129 | |
|---|
| 130 | @parser::members |
|---|
| 131 | { |
|---|
| 132 | /** |
|---|
| 133 | * An empty String String array. |
|---|
| 134 | */ |
|---|
| 135 | public static final String[][] EMPTY_STRING_STRING_ARRAY = new String[0][0]; |
|---|
| 136 | |
|---|
| 137 | /** |
|---|
| 138 | * The table comment. |
|---|
| 139 | */ |
|---|
| 140 | private String tableComment; |
|---|
| 141 | |
|---|
| 142 | /** |
|---|
| 143 | * The table static. |
|---|
| 144 | */ |
|---|
| 145 | private String tableStatic; |
|---|
| 146 | |
|---|
| 147 | /** |
|---|
| 148 | * The table ISA. |
|---|
| 149 | */ |
|---|
| 150 | private String tableIsa; |
|---|
| 151 | |
|---|
| 152 | /** |
|---|
| 153 | * The table ISA-type. |
|---|
| 154 | */ |
|---|
| 155 | private String tableIsaType; |
|---|
| 156 | |
|---|
| 157 | /** |
|---|
| 158 | * The table decorator attribute. |
|---|
| 159 | */ |
|---|
| 160 | private boolean tableDecorator; |
|---|
| 161 | |
|---|
| 162 | /** |
|---|
| 163 | * The table relationship attribute. |
|---|
| 164 | */ |
|---|
| 165 | private String[][] tableRelationship; |
|---|
| 166 | |
|---|
| 167 | /** |
|---|
| 168 | * The column comment. |
|---|
| 169 | */ |
|---|
| 170 | private String columnComment; |
|---|
| 171 | |
|---|
| 172 | /** |
|---|
| 173 | * The column boolean <code>true</code> values. |
|---|
| 174 | */ |
|---|
| 175 | private String columnBoolTrue; |
|---|
| 176 | |
|---|
| 177 | /** |
|---|
| 178 | * The column boolean <code>false</code> values. |
|---|
| 179 | */ |
|---|
| 180 | private String columnBoolFalse; |
|---|
| 181 | |
|---|
| 182 | /** |
|---|
| 183 | * The column boolean <code>null</code> values. |
|---|
| 184 | */ |
|---|
| 185 | private String columnBoolNull; |
|---|
| 186 | |
|---|
| 187 | /** |
|---|
| 188 | * Whether the column is readonly. |
|---|
| 189 | */ |
|---|
| 190 | private boolean columnReadOnly = false;; |
|---|
| 191 | |
|---|
| 192 | /** |
|---|
| 193 | * The column isa-ref mappings. |
|---|
| 194 | */ |
|---|
| 195 | private String[][] columnIsaRefs; |
|---|
| 196 | |
|---|
| 197 | /** |
|---|
| 198 | * The column oraseq attribute. |
|---|
| 199 | */ |
|---|
| 200 | private String columnOraSeq; |
|---|
| 201 | |
|---|
| 202 | /** |
|---|
| 203 | * Specifies the table comment. |
|---|
| 204 | * @param comment such comment. |
|---|
| 205 | */ |
|---|
| 206 | protected void setTableComment(final String comment) |
|---|
| 207 | { |
|---|
| 208 | tableComment = trim(comment); |
|---|
| 209 | } |
|---|
| 210 | |
|---|
| 211 | /** |
|---|
| 212 | * Retrieves the table comment. |
|---|
| 213 | * @return such information. |
|---|
| 214 | */ |
|---|
| 215 | public String getTableComment() |
|---|
| 216 | { |
|---|
| 217 | return tableComment; |
|---|
| 218 | } |
|---|
| 219 | |
|---|
| 220 | /** |
|---|
| 221 | * Specifies the column name used to distinguish the |
|---|
| 222 | * static content. |
|---|
| 223 | * @param name such name. |
|---|
| 224 | */ |
|---|
| 225 | protected void setTableStatic(final String name) |
|---|
| 226 | { |
|---|
| 227 | tableStatic = trim(name); |
|---|
| 228 | } |
|---|
| 229 | |
|---|
| 230 | /** |
|---|
| 231 | * Retrieves the column name used to distinguish the |
|---|
| 232 | * static content. |
|---|
| 233 | * @return such column name. |
|---|
| 234 | */ |
|---|
| 235 | public String getTableStatic() |
|---|
| 236 | { |
|---|
| 237 | return tableStatic; |
|---|
| 238 | } |
|---|
| 239 | |
|---|
| 240 | /** |
|---|
| 241 | * Specifies the table name defined as parent table. |
|---|
| 242 | * @param name such name. |
|---|
| 243 | */ |
|---|
| 244 | protected void setTableIsa(final String name) |
|---|
| 245 | { |
|---|
| 246 | tableIsa = trim(name); |
|---|
| 247 | } |
|---|
| 248 | |
|---|
| 249 | /** |
|---|
| 250 | * Retrieves the table name defined as parent table. |
|---|
| 251 | * @return such table name. |
|---|
| 252 | */ |
|---|
| 253 | public String getTableIsa() |
|---|
| 254 | { |
|---|
| 255 | return tableIsa; |
|---|
| 256 | } |
|---|
| 257 | |
|---|
| 258 | /** |
|---|
| 259 | * Specifies the table name whose descendants get identified |
|---|
| 260 | * by the contents of this table. |
|---|
| 261 | * @param name such name. |
|---|
| 262 | */ |
|---|
| 263 | protected void setTableIsaType(final String name) |
|---|
| 264 | { |
|---|
| 265 | tableIsaType = trim(name); |
|---|
| 266 | } |
|---|
| 267 | |
|---|
| 268 | /** |
|---|
| 269 | * Retrieves the table name whose descendants get identified |
|---|
| 270 | * by the contents of this table. |
|---|
| 271 | * @return such table name. |
|---|
| 272 | */ |
|---|
| 273 | public String getTableIsaType() |
|---|
| 274 | { |
|---|
| 275 | return tableIsaType; |
|---|
| 276 | } |
|---|
| 277 | |
|---|
| 278 | /** |
|---|
| 279 | * Specifies whether the table-specific value-object will be wrapped |
|---|
| 280 | * by custom decorators. |
|---|
| 281 | * @param flag such flag. |
|---|
| 282 | */ |
|---|
| 283 | protected void setTableDecorator(final boolean flag) |
|---|
| 284 | { |
|---|
| 285 | tableDecorator = flag; |
|---|
| 286 | } |
|---|
| 287 | |
|---|
| 288 | /** |
|---|
| 289 | * Retrieves whether the table-specific value-object will be wrapped |
|---|
| 290 | * by custom decorators. |
|---|
| 291 | * @return such information. |
|---|
| 292 | */ |
|---|
| 293 | public boolean getTableDecorator() |
|---|
| 294 | { |
|---|
| 295 | return tableDecorator; |
|---|
| 296 | } |
|---|
| 297 | |
|---|
| 298 | /** |
|---|
| 299 | * Specifies the relationship this table models. |
|---|
| 300 | * @param relationship such content. |
|---|
| 301 | */ |
|---|
| 302 | protected void setTableRelationship(final String[][] relationship) |
|---|
| 303 | { |
|---|
| 304 | tableRelationship = relationship; |
|---|
| 305 | } |
|---|
| 306 | |
|---|
| 307 | /** |
|---|
| 308 | * Retrieves whether the table models a relationship. |
|---|
| 309 | * @return such information. |
|---|
| 310 | */ |
|---|
| 311 | public String[][] getTableRelationship() |
|---|
| 312 | { |
|---|
| 313 | return tableRelationship; |
|---|
| 314 | } |
|---|
| 315 | |
|---|
| 316 | /** |
|---|
| 317 | * Specifies the column comment. |
|---|
| 318 | * @param comment such comment. |
|---|
| 319 | */ |
|---|
| 320 | protected void setColumnComment(final String comment) |
|---|
| 321 | { |
|---|
| 322 | columnComment = trim(comment); |
|---|
| 323 | } |
|---|
| 324 | |
|---|
| 325 | /** |
|---|
| 326 | * Retrieves the column comment. |
|---|
| 327 | * @return such information. |
|---|
| 328 | */ |
|---|
| 329 | public String getColumnComment() |
|---|
| 330 | { |
|---|
| 331 | return columnComment; |
|---|
| 332 | } |
|---|
| 333 | |
|---|
| 334 | /** |
|---|
| 335 | * Specifies the value used as <code>true</code> for boolean attributes. |
|---|
| 336 | * and how it denotes a <code>true</code> value. |
|---|
| 337 | * @param value the value denoting <code>true</code> values. |
|---|
| 338 | */ |
|---|
| 339 | protected void setColumnBoolTrue(final String value) |
|---|
| 340 | { |
|---|
| 341 | columnBoolTrue = value; |
|---|
| 342 | } |
|---|
| 343 | |
|---|
| 344 | /** |
|---|
| 345 | * Retrieves the value used as <code>true</code> for boolean attributes. |
|---|
| 346 | * and how it denotes a <code>true</code> value. |
|---|
| 347 | * @return the <code>true</code> value, or null if |
|---|
| 348 | * the column is not defined as boolean. |
|---|
| 349 | */ |
|---|
| 350 | public String getColumnBoolTrue() |
|---|
| 351 | { |
|---|
| 352 | return columnBoolTrue; |
|---|
| 353 | } |
|---|
| 354 | |
|---|
| 355 | /** |
|---|
| 356 | * Specifies the value used as <code>false</code> for boolean attributes. |
|---|
| 357 | * and how it denotes a <code>false</code> value. |
|---|
| 358 | * @param value the value denoting <code>false</code> values. |
|---|
| 359 | */ |
|---|
| 360 | protected void setColumnBoolFalse(final String value) |
|---|
| 361 | { |
|---|
| 362 | columnBoolFalse = value; |
|---|
| 363 | } |
|---|
| 364 | |
|---|
| 365 | /** |
|---|
| 366 | * Retrieves the value used as <code>false</code> for boolean attributes. |
|---|
| 367 | * and how it denotes a <code>false</code> value. |
|---|
| 368 | * @return the <code>false</code> value, or null if |
|---|
| 369 | * the column is not defined as boolean. |
|---|
| 370 | */ |
|---|
| 371 | public String getColumnBoolFalse() |
|---|
| 372 | { |
|---|
| 373 | return columnBoolFalse; |
|---|
| 374 | } |
|---|
| 375 | |
|---|
| 376 | /** |
|---|
| 377 | * Specifies the value used as <code>null</code> for boolean attributes. |
|---|
| 378 | * and how it denotes a <code>null</code> value. |
|---|
| 379 | * @param value the value denoting <code>null</code> values. |
|---|
| 380 | */ |
|---|
| 381 | protected void setColumnBoolNull(final String value) |
|---|
| 382 | { |
|---|
| 383 | columnBoolNull = value; |
|---|
| 384 | } |
|---|
| 385 | |
|---|
| 386 | /** |
|---|
| 387 | * Retrieves the value used as <code>null</code> for boolean attributes. |
|---|
| 388 | * and how it denotes a <code>null</code> value. |
|---|
| 389 | * @return the <code>null</code> value, or null if |
|---|
| 390 | * the column is not defined as boolean. |
|---|
| 391 | */ |
|---|
| 392 | public String getColumnBoolNull() |
|---|
| 393 | { |
|---|
| 394 | return columnBoolNull; |
|---|
| 395 | } |
|---|
| 396 | |
|---|
| 397 | /** |
|---|
| 398 | * Specifies whether the column is declared as read-only or not. |
|---|
| 399 | * @param flag such flag. |
|---|
| 400 | */ |
|---|
| 401 | protected void setColumnReadOnly(final boolean flag) |
|---|
| 402 | { |
|---|
| 403 | columnReadOnly = flag; |
|---|
| 404 | } |
|---|
| 405 | |
|---|
| 406 | /** |
|---|
| 407 | * Retrieves whether the column is declared as read-only or not. |
|---|
| 408 | * @return such information. |
|---|
| 409 | */ |
|---|
| 410 | public boolean getColumnReadOnly() |
|---|
| 411 | { |
|---|
| 412 | return columnReadOnly; |
|---|
| 413 | } |
|---|
| 414 | |
|---|
| 415 | /** |
|---|
| 416 | * Specifies the associations between column values and |
|---|
| 417 | * table names (ISA implementations). |
|---|
| 418 | * @param mappings the mappings. |
|---|
| 419 | */ |
|---|
| 420 | protected void setColumnIsaRefs(final String[][] mappings) |
|---|
| 421 | { |
|---|
| 422 | columnIsaRefs = mappings; |
|---|
| 423 | } |
|---|
| 424 | |
|---|
| 425 | /** |
|---|
| 426 | * Retrieves the associations between column values and |
|---|
| 427 | * table names (ISA implementations). |
|---|
| 428 | * @return such mappings. |
|---|
| 429 | */ |
|---|
| 430 | public String[][] getColumnIsaRefs() |
|---|
| 431 | { |
|---|
| 432 | return columnIsaRefs; |
|---|
| 433 | } |
|---|
| 434 | |
|---|
| 435 | /** |
|---|
| 436 | * Specifies the 'oraseq' attribute. |
|---|
| 437 | * @param value such value. |
|---|
| 438 | */ |
|---|
| 439 | protected void setColumnOraSeq(final String value) |
|---|
| 440 | { |
|---|
| 441 | columnOraSeq = trim(value); |
|---|
| 442 | } |
|---|
| 443 | |
|---|
| 444 | /** |
|---|
| 445 | * Retrieves the 'oraseq' attribute. |
|---|
| 446 | * @return such information. |
|---|
| 447 | */ |
|---|
| 448 | public String getColumnOraSeq() |
|---|
| 449 | { |
|---|
| 450 | return columnOraSeq; |
|---|
| 451 | } |
|---|
| 452 | |
|---|
| 453 | /** |
|---|
| 454 | * Trims given value. |
|---|
| 455 | * @param value the value. |
|---|
| 456 | */ |
|---|
| 457 | protected String trim(final String value) |
|---|
| 458 | { |
|---|
| 459 | String result = value; |
|---|
| 460 | |
|---|
| 461 | if (result != null) |
|---|
| 462 | { |
|---|
| 463 | result = result.trim(); |
|---|
| 464 | } |
|---|
| 465 | |
|---|
| 466 | return result; |
|---|
| 467 | } |
|---|
| 468 | |
|---|
| 469 | /** |
|---|
| 470 | * Called when a token mismatch occurs. |
|---|
| 471 | * We override it to raise the exception, |
|---|
| 472 | * rather than recovering, on mismatched token within alt. |
|---|
| 473 | * @param input the input. |
|---|
| 474 | * @param type the type. |
|---|
| 475 | * @param follow whatever it means in ANTLR engine. |
|---|
| 476 | * @throws RecognitionException always. |
|---|
| 477 | */ |
|---|
| 478 | protected void mismatch( |
|---|
| 479 | final IntStream input, final int type, final BitSet follow) |
|---|
| 480 | throws RecognitionException |
|---|
| 481 | { |
|---|
| 482 | throw new MismatchedTokenException(type, input); |
|---|
| 483 | } |
|---|
| 484 | } |
|---|
| 485 | |
|---|
| 486 | /*------------------------------------------------------------------ |
|---|
| 487 | * PARSER RULES |
|---|
| 488 | *------------------------------------------------------------------*/ |
|---|
| 489 | |
|---|
| 490 | tableComment : (t=text)? ( tab_annotation )* { setTableComment(t); }; |
|---|
| 491 | |
|---|
| 492 | columnComment : (t=text)? ( col_annotation )* { setColumnComment(t); }; |
|---|
| 493 | |
|---|
| 494 | fragment text returns [String result] |
|---|
| 495 | @init { result = null; StringBuffer aux = new StringBuffer(); } |
|---|
| 496 | : ( t=text_or_id { aux.append($t.text); } |
|---|
| 497 | | c=COMMA { aux.append($c.text); } |
|---|
| 498 | | WS |
|---|
| 499 | | OPEN_PAREN |
|---|
| 500 | | CLOSE_PAREN |
|---|
| 501 | | QUOTE )+ |
|---|
| 502 | { result = aux.toString(); } |
|---|
| 503 | ; |
|---|
| 504 | |
|---|
| 505 | fragment tab_annotation |
|---|
| 506 | : ( |
|---|
| 507 | s=tab_static { setTableStatic(s); } |
|---|
| 508 | | i=tab_isa { setTableIsa(i); } |
|---|
| 509 | | t=tab_isatype { setTableIsaType(t); } |
|---|
| 510 | | tab_decorator { setTableDecorator(true); } |
|---|
| 511 | | tab_relationship |
|---|
| 512 | ) |
|---|
| 513 | ; |
|---|
| 514 | |
|---|
| 515 | fragment tab_static returns [String result] |
|---|
| 516 | @init { result = null; } |
|---|
| 517 | : STATIC WS i=ident WS? { result = $i.text; } |
|---|
| 518 | ; |
|---|
| 519 | |
|---|
| 520 | fragment tab_isa returns [String result] |
|---|
| 521 | @init { result = null; } |
|---|
| 522 | : ISA WS i=ident WS? { result = $i.text; } |
|---|
| 523 | ; |
|---|
| 524 | |
|---|
| 525 | fragment tab_isatype returns [String result] |
|---|
| 526 | @init { result = null; } |
|---|
| 527 | : ISATYPE WS i=ident WS? { result = $i.text; } |
|---|
| 528 | ; |
|---|
| 529 | |
|---|
| 530 | fragment tab_decorator : DECORATOR WS?; |
|---|
| 531 | |
|---|
| 532 | fragment tab_relationship |
|---|
| 533 | @init |
|---|
| 534 | { |
|---|
| 535 | List contents = new ArrayList(); |
|---|
| 536 | String first = null; |
|---|
| 537 | String second = null; |
|---|
| 538 | } |
|---|
| 539 | : RELATIONSHIP |
|---|
| 540 | WS |
|---|
| 541 | ( |
|---|
| 542 | OPEN_PAREN WS? |
|---|
| 543 | ( (SQUOTE a=text_or_id SQUOTE) { first = $a.text; } |
|---|
| 544 | | (DQUOTE b=text_or_id DQUOTE) { first = $b.text; } |
|---|
| 545 | | (c=text_or_id) { first = $c.text; }) |
|---|
| 546 | WS? COMMA WS? |
|---|
| 547 | ( (SQUOTE d=ID SQUOTE) { second = $d.text; } |
|---|
| 548 | | (DQUOTE e=ID DQUOTE) { second = $e.text; } |
|---|
| 549 | | (f=ID) { second = $f.text; }) |
|---|
| 550 | WS? CLOSE_PAREN WS? COMMA? |
|---|
| 551 | { |
|---|
| 552 | contents.add(new String[] { trim(first), trim(second) }); |
|---|
| 553 | } |
|---|
| 554 | )+ |
|---|
| 555 | { |
|---|
| 556 | setTableRelationship((String[][]) contents.toArray(new String[0][0])); |
|---|
| 557 | } |
|---|
| 558 | ; |
|---|
| 559 | |
|---|
| 560 | fragment col_annotation |
|---|
| 561 | : ( |
|---|
| 562 | col_readonly { setColumnReadOnly(true); } |
|---|
| 563 | | col_bool |
|---|
| 564 | | col_isarefs |
|---|
| 565 | | s=col_oraseq { setColumnOraSeq(s); } |
|---|
| 566 | ); |
|---|
| 567 | |
|---|
| 568 | fragment col_readonly : READONLY WS?; |
|---|
| 569 | |
|---|
| 570 | fragment col_bool |
|---|
| 571 | : BOOL WS |
|---|
| 572 | i=ident |
|---|
| 573 | { |
|---|
| 574 | setColumnBoolTrue($i.text); |
|---|
| 575 | } |
|---|
| 576 | WS? COMMA WS? |
|---|
| 577 | j=ident { setColumnBoolFalse($j.text); } |
|---|
| 578 | WS? (COMMA WS? k=ident WS? { setColumnBoolNull($k.text); })? |
|---|
| 579 | ; |
|---|
| 580 | |
|---|
| 581 | fragment text_or_id |
|---|
| 582 | : ID |
|---|
| 583 | | TEXT |
|---|
| 584 | ; |
|---|
| 585 | |
|---|
| 586 | fragment ident returns [String text] |
|---|
| 587 | @init {text = null;} |
|---|
| 588 | : (SQUOTE i=ID SQUOTE) {text = ($i.text);} |
|---|
| 589 | | (DQUOTE j=ID DQUOTE) {text = ($j.text);} |
|---|
| 590 | | k=ID {text = $k.text;} |
|---|
| 591 | ; |
|---|
| 592 | |
|---|
| 593 | fragment col_isarefs |
|---|
| 594 | @init |
|---|
| 595 | { |
|---|
| 596 | List contents = new ArrayList(); |
|---|
| 597 | String first = null; |
|---|
| 598 | String second = null; |
|---|
| 599 | } |
|---|
| 600 | : ISAREFS |
|---|
| 601 | WS |
|---|
| 602 | ( |
|---|
| 603 | OPEN_PAREN WS? |
|---|
| 604 | ( (SQUOTE a=text_or_id SQUOTE) { first = $a.text; } |
|---|
| 605 | | (DQUOTE b=text_or_id DQUOTE) { first = $b.text; } |
|---|
| 606 | | (c=text_or_id) { first = $c.text; }) |
|---|
| 607 | WS? COMMA WS? |
|---|
| 608 | ( (SQUOTE d=ID SQUOTE) { second = $d.text; } |
|---|
| 609 | | (DQUOTE e=ID DQUOTE) { second = $e.text; } |
|---|
| 610 | | (f=ID) { second = $f.text; }) |
|---|
| 611 | WS? CLOSE_PAREN WS? COMMA? |
|---|
| 612 | { |
|---|
| 613 | contents.add(new String[] { trim(first), trim(second) }); |
|---|
| 614 | } |
|---|
| 615 | )+ |
|---|
| 616 | { |
|---|
| 617 | setColumnIsaRefs((String[][]) contents.toArray(new String[0][0])); |
|---|
| 618 | } |
|---|
| 619 | ; |
|---|
| 620 | |
|---|
| 621 | fragment col_oraseq returns [String result] |
|---|
| 622 | @init { result = null; } |
|---|
| 623 | : ORASEQ WS i=ident WS? { result = $i.text; } |
|---|
| 624 | ; |
|---|
| 625 | |
|---|
| 626 | /*------------------------------------------------------------------ |
|---|
| 627 | * LEXER RULES |
|---|
| 628 | *------------------------------------------------------------------*/ |
|---|
| 629 | |
|---|
| 630 | AT |
|---|
| 631 | : ( ('@static') => STATIC {$type = STATIC;} |
|---|
| 632 | | ('@isa') => ISA {$type = ISA;} |
|---|
| 633 | | ('@isatype') => ISATYPE {$type = ISATYPE;} |
|---|
| 634 | | ('@decorator') => DECORATOR {$type = DECORATOR;} |
|---|
| 635 | | ('@isarefs') => ISAREFS {$type = ISAREFS;} |
|---|
| 636 | | ('@readonly') => READONLY {$type = READONLY;} |
|---|
| 637 | | ('@bool') => BOOL {$type = BOOL;} |
|---|
| 638 | | ('@oraseq') => ORASEQ {$type = ORASEQ;} |
|---|
| 639 | | ('@relationship') => RELATIONSHIP {$type = RELATIONSHIP;} |
|---|
| 640 | | '@') |
|---|
| 641 | ; |
|---|
| 642 | |
|---|
| 643 | SQUOTE : ('\''); |
|---|
| 644 | DQUOTE : ('"'); |
|---|
| 645 | fragment QUOTE : (SQUOTE | DQUOTE); |
|---|
| 646 | |
|---|
| 647 | // literals |
|---|
| 648 | OPEN_PAREN : '('; |
|---|
| 649 | CLOSE_PAREN : ')'; |
|---|
| 650 | COMMA : ','; |
|---|
| 651 | |
|---|
| 652 | // keywords |
|---|
| 653 | fragment STATIC : '@static'; |
|---|
| 654 | fragment ISA : '@isa'; |
|---|
| 655 | fragment ISATYPE : '@isatype'; |
|---|
| 656 | fragment DECORATOR : '@decorator'; |
|---|
| 657 | fragment ISAREFS : '@isarefs'; |
|---|
| 658 | fragment READONLY : '@readonly'; |
|---|
| 659 | fragment RELATIONSHIP : '@relationship'; |
|---|
| 660 | fragment BOOL : '@bool'; |
|---|
| 661 | fragment ORASEQ : '@oraseq'; |
|---|
| 662 | |
|---|
| 663 | WS : ( '\t' | ' ' | '\r' | '\n'| '\u000C' )+;// {$channel = HIDDEN;}; |
|---|
| 664 | |
|---|
| 665 | ID |
|---|
| 666 | : (LETTER | '_' | DIGIT ) (NAMECHAR)* WS? {$type = ID;} |
|---|
| 667 | ; |
|---|
| 668 | |
|---|
| 669 | TEXT |
|---|
| 670 | : ( (ID) => ID {$type = ID;} |
|---|
| 671 | | ('\t') => WS {$type = WS;} |
|---|
| 672 | | (' ') => WS {$type = WS;} |
|---|
| 673 | | ('\r') => WS {$type = WS;} |
|---|
| 674 | | ('\n') => WS {$type = WS;} |
|---|
| 675 | | ('\u000C') => WS {$type = WS;} |
|---|
| 676 | | ('(') => OPEN_PAREN {$type = OPEN_PAREN;} |
|---|
| 677 | | (')') => CLOSE_PAREN {$type = CLOSE_PAREN;} |
|---|
| 678 | | (',') => COMMA {$type = COMMA;} |
|---|
| 679 | | ('\''|'"') => QUOTE {$type = QUOTE;} |
|---|
| 680 | | ('@') => AT |
|---|
| 681 | | (~('@'|','|'('|')'|'\''|'"')+)) |
|---|
| 682 | ; |
|---|
| 683 | |
|---|
| 684 | fragment NAMECHAR |
|---|
| 685 | : LETTER | DIGIT | '.' | '-' | '_' | ':' | '$' |
|---|
| 686 | ; |
|---|
| 687 | |
|---|
| 688 | fragment DIGIT |
|---|
| 689 | : '0'..'9' |
|---|
| 690 | ; |
|---|
| 691 | |
|---|
| 692 | fragment LETTER |
|---|
| 693 | : 'a'..'z' |
|---|
| 694 | | 'A'..'Z' |
|---|
| 695 | ; |
|---|