Scanner::Esqlc - makepp scanner for Embedded SQL C files


makepp documentation Contained in the makepp distribution.

Index


Code Index:

NAME

Top

Scanner::Esqlc - makepp scanner for Embedded SQL C files

DESCRIPTION

Top

Scans a C file for EXEC SQL INCLUDEs, $includes and #includes.

Tags are:

user

File scanned due to an EXEC SQL INCLUDE "filename" or $INCLUDE "filename" directive.

sys

File scanned due to an EXEC SQL INCLUDE <filename<, EXEC SQL INCLUDE filename or $INCLUDE <filename< directive.

sql

makepp documentation Contained in the makepp distribution.

use strict;
package Scanner::Esqlc;

use Scanner::C;
our @ISA = 'Scanner::C';

sub get_directive {
  if( s/^\s*(?:EXEC\s+SQL\s+|\$\s*)INCLUDE\s+//i ) {
    'sql';
  } elsif( s/^\s*EXEC\s+ORACLE\s+// ) {
      if( s/^(DEFINE|IFN?DEF)(\s+\w+)\s*;/$2/i || s/^(ELSE|ENDIF)\s*;//i ) {
	lc $1;
      }
  } else {
    &Scanner::C::get_directive;
  }
}

sub other_directive {
  my( $self, $cp, $finfo, $conditional, $tag, $scanworthy ) = @_;
  return 0 unless $tag eq 'sql';
  $_ = $self->expand_macros($_) if $conditional;
  $$scanworthy = 1;
  if( s/^(<)(.+?)>\s*;?\s*$// or s/^(['"]?)(.+?)\1\s*;?\s*$// ) {
    $tag = ($1 eq '<') ? 'sys' : 'user';
    my $file = $1 ? $2 : lc $2; # downcase unquoted file
    $self->include( $cp, $tag, $file, $finfo )
      or undef;
  }
}

1;