Class: LanguageParser::PostgreSQLScanner
- Inherits:
-
SQLLanguageScanner
- Object
- LanguageScanner
- SQLLanguageScanner
- LanguageParser::PostgreSQLScanner
- Defined in:
- lib/cgialib/lp/SQLLanguageScanner.rb
Overview
class : PostgreSQLScanner
An SQLLanguageScanner specialized to read PostgreSQL.
Instance Attribute Summary collapse
-
#prototypeClass ⇒ Object
The prototype class to build.
-
#prototypes ⇒ Object
readonly
The array of prototypes found.
Attributes inherited from SQLLanguageScanner
#fieldClass, #tableClass, #tables
Instance Method Summary collapse
-
#initialize ⇒ PostgreSQLScanner
constructor
initialize().
-
#parse(tokens) ⇒ Object
parse( tokens ).
-
#to_s ⇒ Object
to_s().
Constructor Details
#initialize ⇒ PostgreSQLScanner
initialize()
Constuctor
450 451 452 453 454 455 456 457 458 459 460 461 462 463 |
# File 'lib/cgialib/lp/SQLLanguageScanner.rb', line 450 def initialize() # Create the prototype array @prototypes = [] # Set the prototype class to build to the default # prototype class @prototypeClass = Prototype super() end |
Instance Attribute Details
#prototypeClass ⇒ Object
The prototype class to build
466 467 468 |
# File 'lib/cgialib/lp/SQLLanguageScanner.rb', line 466 def prototypeClass @prototypeClass end |
#prototypes ⇒ Object (readonly)
The array of prototypes found
465 466 467 |
# File 'lib/cgialib/lp/SQLLanguageScanner.rb', line 465 def prototypes @prototypes end |
Instance Method Details
#parse(tokens) ⇒ Object
parse( tokens )
tokens - Tokens returned from SQLTokenizer
An override of the parser to add parsing of stored procedure prototypes
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 |
# File 'lib/cgialib/lp/SQLLanguageScanner.rb', line 497 def parse( tokens ) super( tokens ) # This is the code fragment leading up to the interior # of the function codefrag = TokenStream.new() has_create = false building_function = false waiting_for_language = false # Look through each token comment = "" tokens.each_index { |index| tok = tokens[ index ] if tok.to_s =~ /^create$/i comment = tokens.get_comments( index ) has_create = true elsif waiting_for_language waiting_for_language = false if tok.to_s =~ /^language$/ elsif tok.to_s =~ /^function$/i && has_create building_function = true elsif tok.to_s =~ /^declare$/i && building_function parse_function( codefrag, comment ) codefrag = TokenStream.new() building_function = false has_create = false waiting_for_language = true comment = "" elsif building_function codefrag.push( tok ) end } end |
#to_s ⇒ Object
to_s()
Pretty prints the result
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 |
# File 'lib/cgialib/lp/SQLLanguageScanner.rb', line 472 def to_s() text = "Prototypes:\n" @prototypes.each { |proto| text += " #{proto}\n" } text += "\nPrototypes:\n" @prototypes.each { |proto| text += " #{proto}\n" } text += "\n" text end |