swig/Source/CParse/cscanner.c
Jamie Kirkpatrick 825e67b2b0 Merged revisions 10487,10498-10499,10503-10504,10506,10508,10511,10515-10516,10518-10519,10527,10530-10531,10536-10537,10539-10552,10558-10568,10574-10580,10582,10584,10588-10589,10594,10607-10610,10616,10621,10624-10629,10633-10641,10643,10647,10649-10650,10662,10672,10676-10677,10682-10683,10714,10726-10727,10738,10743,10747,10749,10794,10801-10809,10827-10831,10834 via svnmerge from
https://swig.svn.sourceforge.net/svnroot/swig/trunk

................
  r10487 | wsfulton | 2008-05-21 23:15:52 +0100 (Wed, 21 May 2008) | 1 line
  
  Apply patch from Petr Viktorin to fix some recent regressions in CFFI/CLOS
................
  r10498 | talby | 2008-05-26 21:09:56 +0100 (Mon, 26 May 2008) | 2 lines
  
  run test cases in the Perl set by the --with-perl5 configure option.
................
  r10499 | talby | 2008-05-26 22:04:06 +0100 (Mon, 26 May 2008) | 3 lines
  
  The perl5 minherit runtime test will work better if the classes are 
  actually built under SWIGPERL.
................
  r10503 | wsfulton | 2008-05-28 10:44:37 +0100 (Wed, 28 May 2008) | 1 line
  
  Fix variable wrappers when using -proxy. Patch from Jan Jezabek
................
  r10504 | bhy | 2008-05-28 18:27:48 +0100 (Wed, 28 May 2008) | 2 lines
  
  Fixed SF #1971977:  typo in pycontainer.swg (related to -extranative option)
................
  r10506 | wsfulton | 2008-05-29 01:45:28 +0100 (Thu, 29 May 2008) | 1 line
  
  Fix variable wrappers when using -noproxy
................
  r10508 | bhy | 2008-05-30 14:53:33 +0100 (Fri, 30 May 2008) | 1 line
  
  Fixed SF #1976978, apply the macros for primitive types to std::wstring
................
  r10511 | olly | 2008-05-30 17:11:27 +0100 (Fri, 30 May 2008) | 4 lines
  
  Fix typo in handling of /*@SWIG[...]*/ comments in the scanner.  This just
  meant we were only actually looking for /*@SWI at the start of the comment, so
  was pretty harmless in practice.
................
  r10515 | wsfulton | 2008-06-02 21:10:40 +0100 (Mon, 02 Jun 2008) | 1 line
  
  Fix samename testcase for c# and java
................
  r10516 | wsfulton | 2008-06-02 21:15:39 +0100 (Mon, 02 Jun 2008) | 1 line
  
  Fix enums when using -noproxy
................
  r10518 | bhy | 2008-06-07 12:20:07 +0100 (Sat, 07 Jun 2008) | 4 lines
  
  Added a test case for keyword renaming.
  Now it works for Python in SWIG's -c++ mode,
  but in C mode it doesn't work! (you can try with make keyword_rename.ctest)
................
  r10519 | bhy | 2008-06-07 14:40:51 +0100 (Sat, 07 Jun 2008) | 1 line
  
  fixed keyword_rename.ctest tese case, caused by a mistake in Swig/naming.c
................
  r10527 | mgossage | 2008-06-17 03:57:15 +0100 (Tue, 17 Jun 2008) | 1 line
  
  [lua] bugfix 1938142 (bool& and bool* support)
................
  r10530 | wsfulton | 2008-06-19 21:02:13 +0100 (Thu, 19 Jun 2008) | 1 line
  
  Add R keyword support. Rename keywords for successful compilation of Java and C# code. More consistent keyword warnings across the different languages.
................
  r10531 | wsfulton | 2008-06-19 22:15:48 +0100 (Thu, 19 Jun 2008) | 1 line
  
  add complete list of R reserved words
................
  r10536 | wsfulton | 2008-06-21 12:35:33 +0100 (Sat, 21 Jun 2008) | 1 line
  
  better terminology for static types
................
  r10537 | wsfulton | 2008-06-21 12:42:48 +0100 (Sat, 21 Jun 2008) | 1 line
  
  remove raise as keyword test- it conflicts with _raise in LIBCMT on windows
................
  r10539 | wsfulton | 2008-06-21 16:21:29 +0100 (Sat, 21 Jun 2008) | 1 line
  
  Lua example warning removal fixes for vc++
................
  r10540 | wsfulton | 2008-06-21 16:23:02 +0100 (Sat, 21 Jun 2008) | 1 line
  
  Remove some vc++ /W4 warnings
................
  r10541 | wsfulton | 2008-06-21 17:04:55 +0100 (Sat, 21 Jun 2008) | 1 line
  
  minor vc++ /W4 warning fixes
................
  r10542 | wsfulton | 2008-06-21 20:07:51 +0100 (Sat, 21 Jun 2008) | 1 line
  
  'byte' is already used in Ruby on windows, so use another keyword
................
  r10543 | wsfulton | 2008-06-21 21:45:32 +0100 (Sat, 21 Jun 2008) | 1 line
  
  Fix crashing in the Ruby reject method in the STL wrappers
................
  r10544 | wsfulton | 2008-06-21 21:48:28 +0100 (Sat, 21 Jun 2008) | 1 line
  
  Fix crashing in the Ruby reject method in the STL wrappers
................
  r10545 | wsfulton | 2008-06-21 21:49:10 +0100 (Sat, 21 Jun 2008) | 1 line
  
  remove unnecessary variable int the char **STRING_ARRAY out typemap
................
  r10546 | wsfulton | 2008-06-21 22:07:49 +0100 (Sat, 21 Jun 2008) | 1 line
  
  Fix Ruby C++ example dependencies in dsp files
................
  r10547 | wsfulton | 2008-06-21 23:25:36 +0100 (Sat, 21 Jun 2008) | 1 line
  
  Fix unused parameter warnings in python when using gcc's -W -Wall options
................
  r10548 | wsfulton | 2008-06-21 23:26:35 +0100 (Sat, 21 Jun 2008) | 1 line
  
  Fix virtual destructor
................
  r10549 | wsfulton | 2008-06-22 00:25:20 +0100 (Sun, 22 Jun 2008) | 1 line
  
  various warning fixes
................
  r10550 | wsfulton | 2008-06-22 01:09:11 +0100 (Sun, 22 Jun 2008) | 1 line
  
  Another fix for the JVM hanging on exit problem when using directors
................
  r10551 | wsfulton | 2008-06-22 01:09:51 +0100 (Sun, 22 Jun 2008) | 1 line
  
  documentation sections update
................
  r10552 | wsfulton | 2008-06-22 01:18:10 +0100 (Sun, 22 Jun 2008) | 1 line
  
  more docs on defining macros for the thread hanging problem
................
  r10558 | wsfulton | 2008-06-22 22:30:20 +0100 (Sun, 22 Jun 2008) | 1 line
  
  fix unused parms in last commit for C code
................
  r10559 | wsfulton | 2008-06-22 23:12:43 +0100 (Sun, 22 Jun 2008) | 1 line
  
  Suppress unused methods warning for VC++
................
  r10560 | wsfulton | 2008-06-23 21:26:07 +0100 (Mon, 23 Jun 2008) | 1 line
  
  fix partialcheck-test-suite and parallel make for r, chicken, tcl and php
................
  r10561 | wsfulton | 2008-06-23 21:39:41 +0100 (Mon, 23 Jun 2008) | 1 line
  
  correct message display when running the partialcheck-test-suite make target
................
  r10562 | wsfulton | 2008-06-23 22:14:53 +0100 (Mon, 23 Jun 2008) | 1 line
  
  fix typo
................
  r10563 | olly | 2008-06-23 22:23:54 +0100 (Mon, 23 Jun 2008) | 3 lines
  
  Fix bad use of Python API (untested, since I can't even compile this code on
  x86-64!)
................
  r10564 | olly | 2008-06-23 23:58:03 +0100 (Mon, 23 Jun 2008) | 3 lines
  
  [PHP] Fix segfault when wrapping a non-class function marked with
  %newobject (testcase char_strings).
................
  r10565 | olly | 2008-06-24 01:27:34 +0100 (Tue, 24 Jun 2008) | 3 lines
  
  [PHP] Fix assertion failure when handling %typemap(in,numinputs=0)
  (testcase ignore_parameter).
................
  r10566 | olly | 2008-06-24 01:33:08 +0100 (Tue, 24 Jun 2008) | 2 lines
  
  [PHP] Fix typemap_namespace.i to not try to copy a non-existent typemap.
................
  r10567 | olly | 2008-06-24 01:41:07 +0100 (Tue, 24 Jun 2008) | 3 lines
  
  Clean up dead and unused code in SwigToPhpType(), and rename to
  GetShadowReturnType().
................
  r10568 | olly | 2008-06-24 01:42:29 +0100 (Tue, 24 Jun 2008) | 2 lines
  
  Fix cosmetic typo in string constant.
................
  r10574 | wsfulton | 2008-06-24 21:10:28 +0100 (Tue, 24 Jun 2008) | 1 line
  
  zap last entry
................
  r10575 | wsfulton | 2008-06-24 21:11:46 +0100 (Tue, 24 Jun 2008) | 1 line
  
  variable name changes to remove php keywords
................
  r10576 | wsfulton | 2008-06-24 21:12:08 +0100 (Tue, 24 Jun 2008) | 1 line
  
  variable name hiding fix
................
  r10577 | wsfulton | 2008-06-24 21:12:43 +0100 (Tue, 24 Jun 2008) | 1 line
  
  More info about numobjects added
................
  r10578 | wsfulton | 2008-06-24 21:13:41 +0100 (Tue, 24 Jun 2008) | 1 line
  
  update for 1.3.36 release
................
  r10579 | wsfulton | 2008-06-24 22:48:46 +0100 (Tue, 24 Jun 2008) | 1 line
  
  remove deprecated -c commandline option (runtime library generation)
................
  r10580 | wsfulton | 2008-06-24 22:53:12 +0100 (Tue, 24 Jun 2008) | 1 line
  
  correct comment about deprecated option
................
  r10582 | wsfulton | 2008-06-25 00:00:27 +0100 (Wed, 25 Jun 2008) | 1 line
  
  use rsync and ssh to upload releases to SourceForge as ftp no longer works
................
  r10584 | wsfulton | 2008-06-25 00:24:48 +0100 (Wed, 25 Jun 2008) | 1 line
  
  correction for 1.3.36
................
  r10588 | wsfulton | 2008-06-25 01:16:04 +0100 (Wed, 25 Jun 2008) | 1 line
  
  section update
................
  r10589 | wsfulton | 2008-06-25 01:16:40 +0100 (Wed, 25 Jun 2008) | 1 line
  
  bump version to 1.3.37
................
  r10594 | wsfulton | 2008-06-26 19:33:06 +0100 (Thu, 26 Jun 2008) | 1 line
  
  correct typo in first entry about %fragment
................
  r10607 | wsfulton | 2008-06-29 01:19:05 +0100 (Sun, 29 Jun 2008) | 1 line
  
  fix some potential null pointer usage as reported by CoveriCoverity Prevent
................
  r10608 | wsfulton | 2008-06-29 01:50:27 +0100 (Sun, 29 Jun 2008) | 1 line
  
  fix potential null pointer usage as reported by Coverity Prevent
................
  r10609 | wsfulton | 2008-06-29 10:57:41 +0100 (Sun, 29 Jun 2008) | 1 line
  
  make life easier for svn status updates as everyone has different autotool versions installed - use svn:ignore on config.sub and config.guess
................
  r10610 | wsfulton | 2008-06-29 11:08:14 +0100 (Sun, 29 Jun 2008) | 1 line
  
  make life easier for svn status updates as everyone has different autotool versions installed - use svn:ignore on config.sub and config.guess
................
  r10616 | talby | 2008-07-01 00:41:27 +0100 (Tue, 01 Jul 2008) | 2 lines
  
  Hopefully this provides more portable values for Infinity and NaN in Perl.
................
  r10621 | wsfulton | 2008-07-01 23:02:14 +0100 (Tue, 01 Jul 2008) | 1 line
  
  update old commandline option
................
  r10624 | olly | 2008-07-02 04:17:46 +0100 (Wed, 02 Jul 2008) | 5 lines
  
  [Python] Import the C extension differently for Python 2.6 and
  later so that an implicit relative import doesn't produce a
  deprecation warning for 2.6 and a failure for 2.7 and later.
  Patch from Richard Boulton in SF#2008229.
................
  r10625 | bhy | 2008-07-02 05:56:11 +0100 (Wed, 02 Jul 2008) | 1 line
  
  fix the relative import patch by try both relative and absolute import
................
  r10626 | olly | 2008-07-02 06:55:18 +0100 (Wed, 02 Jul 2008) | 4 lines
  
  [PHP4] Support for PHP4 has been removed.  The PHP developers are
  no longer making new PHP4 releases, and won't even be patching
  critical security issues after 2008-08-08.
................
  r10627 | bhy | 2008-07-02 07:06:56 +0100 (Wed, 02 Jul 2008) | 1 line
  
  fix the previous commit -- new approach using imp module
................
  r10628 | bhy | 2008-07-02 07:29:15 +0100 (Wed, 02 Jul 2008) | 1 line
  
  minor fix on relative import: close fp if exception occured during imp.find_module
................
  r10629 | bhy | 2008-07-02 08:08:00 +0100 (Wed, 02 Jul 2008) | 1 line
  
  reconstruct the relative import, now the generated code looks better
................
  r10633 | olly | 2008-07-03 01:09:56 +0100 (Thu, 03 Jul 2008) | 9 lines
  
  WARN_* constants are user visible, so keep existing WARN_PHP4_* for
  backward compatibility, but add preferred forms WARN_PHP_* and use
  these ourselves.
  
  Rename Lib/php4 to Lib/php, Source/Modules/php4.cxx to Source/Modules/php.cxx.
   
  Add typemaps for const reference so Examples/test-suite/apply_signed_char.i
  works.
................
  r10634 | olly | 2008-07-03 01:12:58 +0100 (Thu, 03 Jul 2008) | 2 lines
  
  Remove file added in error.
................
  r10635 | olly | 2008-07-03 01:37:38 +0100 (Thu, 03 Jul 2008) | 2 lines
  
  Rename php4*.swg to php*.swg.
................
  r10636 | olly | 2008-07-03 02:13:51 +0100 (Thu, 03 Jul 2008) | 2 lines
  
  Update wrt PHP4.
................
  r10637 | olly | 2008-07-03 03:32:11 +0100 (Thu, 03 Jul 2008) | 4 lines
  
  [PHP] The deprecated command line option "-phpfull" has been
  removed.  We recommend building your extension as a dynamically
  loadable module.
................
  r10638 | olly | 2008-07-03 03:32:41 +0100 (Thu, 03 Jul 2008) | 2 lines
  
  Fix version number
................
  r10639 | olly | 2008-07-03 07:04:24 +0100 (Thu, 03 Jul 2008) | 2 lines
  
  Make t_output_helper() static.
................
  r10640 | olly | 2008-07-03 07:05:34 +0100 (Thu, 03 Jul 2008) | 2 lines
  
  Make testcase li_typemaps work for PHP.
................
  r10641 | olly | 2008-07-03 10:12:16 +0100 (Thu, 03 Jul 2008) | 2 lines
  
  Fix check::classname() to compare case-insensitively and not try to interpolate objects into strings.
................
  r10643 | olly | 2008-07-03 23:00:01 +0100 (Thu, 03 Jul 2008) | 4 lines
  
  The operator& trick in allowexcept.i doesn't work for SWIG/PHP because the
  generated code takes the address of the variable in the code in the "vinit"
  section.  So comment out the private operator& for PHP.
................
  r10647 | olly | 2008-07-04 00:55:33 +0100 (Fri, 04 Jul 2008) | 2 lines
  
  [PHP] The SWIG cdata.i library module is now supported.
................
  r10649 | olly | 2008-07-04 02:02:22 +0100 (Fri, 04 Jul 2008) | 4 lines
  
  [PHP] The deprecated command line option "-make" has been removed.  
  Searches on Google codesearch suggest that nobody is using it now
  anyway.
................
  r10650 | olly | 2008-07-04 02:22:11 +0100 (Fri, 04 Jul 2008) | 4 lines
  
  [PHP] For std_vector.i and std_map.i, rename empty() to is_empty()
  since "empty" is a PHP reserved word.  Based of patch from Mark Klein
  in SF#1943417.
................
  r10662 | wsfulton | 2008-07-14 22:09:23 +0100 (Mon, 14 Jul 2008) | 1 line
  
  Fix director typemaps for pointers so that NULL pointers are correctly marshalled to C#/Java null in director methods
................
  r10672 | olly | 2008-07-17 02:17:08 +0100 (Thu, 17 Jul 2008) | 2 lines
  
  Fix a typo; improve wording.
................
  r10676 | wsfulton | 2008-07-17 22:05:49 +0100 (Thu, 17 Jul 2008) | 1 line
  
  SF #2019156 Configuring with --without-octave or --without-alllang did not disable octave.
................
  r10677 | wsfulton | 2008-07-17 22:08:22 +0100 (Thu, 17 Jul 2008) | 1 line
  
  tidy output after detecting X11 headers
................
  r10682 | wsfulton | 2008-07-19 19:08:06 +0100 (Sat, 19 Jul 2008) | 1 line
  
  a bit more on pgcpp
................
  r10683 | wsfulton | 2008-07-19 23:45:54 +0100 (Sat, 19 Jul 2008) | 1 line
  
  Fix building of Tcl examples/test-suite on Mac OSX
................
  r10714 | olly | 2008-07-27 13:51:16 +0100 (Sun, 27 Jul 2008) | 2 lines
  
  Fix "can can" typo in docs (SF#2026756)
................
  r10726 | wuzzeb | 2008-08-02 09:28:02 +0100 (Sat, 02 Aug 2008) | 1 line
  
  Commit patch 2019314
................
  r10727 | wuzzeb | 2008-08-02 09:49:43 +0100 (Sat, 02 Aug 2008) | 1 line
  
  add assert.h to fix chicken build of external runtime (ext_test testsuite)
................
  r10738 | talby | 2008-08-07 07:28:13 +0100 (Thu, 07 Aug 2008) | 2 lines
  
  hoist globals to local scope where trival.
................
  r10743 | talby | 2008-08-08 04:10:55 +0100 (Fri, 08 Aug 2008) | 2 lines
  
  initial steps to clean up perl5 class methods (primarily constructors).
................
  r10747 | talby | 2008-08-09 05:08:26 +0100 (Sat, 09 Aug 2008) | 2 lines
  
  moves perl space constructor fixups into wrapper code.
................
  r10749 | talby | 2008-08-10 00:57:55 +0100 (Sun, 10 Aug 2008) | 2 lines
  
  usage_func() fix + CHANGES.current entry to explain my past few commits.
................
  r10794 | talby | 2008-08-19 08:09:29 +0100 (Tue, 19 Aug 2008) | 3 lines
  
  rollback 10737:10749, this work is better left on a branch until it is 
  in support a significant feature enhancement.
................
  r10801 | drjoe | 2008-08-31 17:07:43 +0100 (Sun, 31 Aug 2008) | 2 lines
  
  change Rf_warning to warning.  Looks like a typo
................
  r10802 | wsfulton | 2008-09-01 20:59:23 +0100 (Mon, 01 Sep 2008) | 1 line
  
  Fix ruby detection problem breaking configure
................
  r10803 | wsfulton | 2008-09-01 21:00:28 +0100 (Mon, 01 Sep 2008) | 1 line
  
  Fix another perl global namespace pollution
................
  r10804 | wsfulton | 2008-09-01 21:32:53 +0100 (Mon, 01 Sep 2008) | 1 line
  
  Fix array bounds checking in C# std::vector wrappers
................
  r10805 | wsfulton | 2008-09-01 21:34:49 +0100 (Mon, 01 Sep 2008) | 1 line
  
  fix runtime problem in Ruby std_vector example
................
  r10806 | wsfulton | 2008-09-01 21:42:40 +0100 (Mon, 01 Sep 2008) | 1 line
  
  Fix portability problem using /dev/null
................
  r10807 | wsfulton | 2008-09-01 22:46:41 +0100 (Mon, 01 Sep 2008) | 1 line
  
  patch #2079381 submitted by Boris Smilga - constant exprs put into no-eval context in DEFCENUM
................
  r10808 | wsfulton | 2008-09-02 21:56:52 +0100 (Tue, 02 Sep 2008) | 1 line
  
  Add new terminator attribute for the csin typemap for C#
................
  r10809 | wsfulton | 2008-09-03 00:01:37 +0100 (Wed, 03 Sep 2008) | 1 line
  
  Fix #1988296 - Multiple module director linking issue
................
  r10827 | richardb | 2008-09-10 11:08:21 +0100 (Wed, 10 Sep 2008) | 6 lines
  
  [Python] Commit patch #2089149: Director exception handling mangles
  returned exception.  Exceptions raised by Python code in directors
  are now passed through to the caller without change.  Also, remove
  the ": " prefix which used to be added to other director exceptions
  (eg, those due to incorrect return types).
................
  r10828 | bhy | 2008-09-10 11:45:33 +0100 (Wed, 10 Sep 2008) | 3 lines
  
  Initialized merge tracking via "svnmerge" with revisions "1-10827" from 
  https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-bhy
................
  r10829 | bhy | 2008-09-10 12:04:09 +0100 (Wed, 10 Sep 2008) | 4 lines
  
  Removed merge tracking for "svnmerge" for 
  https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-bhy
  (Undo the init due to user error)
................
  r10830 | bhy | 2008-09-10 12:08:16 +0100 (Wed, 10 Sep 2008) | 3 lines
  
  Initialized merge tracking via "svnmerge" with revisions "1-10403" from 
  https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-bhy
................
  r10831 | bhy | 2008-09-10 12:51:12 +0100 (Wed, 10 Sep 2008) | 11 lines
  
  (Still trying to set right properity to get svnmerge work...)
  Recorded merge of revisions 10404 via svnmerge from 
  https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-bhy
  
  ........
    r10404 | bhy | 2008-05-01 08:35:49 +0800 (Thu, 01 May 2008) | 5 lines
    
    Start of gsoc2008-bhy branch. This is a branch for Haoyu Bai's Python 3.0 backend project.
    Some file already modified since a little of work already done when starting the branch. 
  ........
................
  r10834 | bhy | 2008-09-11 18:18:07 +0100 (Thu, 11 Sep 2008) | 8 lines
  
  Merged the Python 3.0 support branch. The merging progress is not so smooth, so hope this commit won't make anything broken.
  
  This is the (incomplemete) log produced by svnmerge.py:
  
  Merged revisions 10405-10409,10420-10422,10426,10438,10445,10451,10454-10465,10467,10473-10475,10485,10488-10489,10493-10495,10497,10509-10510,10513-10514,10517,10520,10525,10528-10529,10533-10535,10554-10557,10570,10573,10593,10614,10666-10669,10673,10678,10687,10690,10704-10706,10731,10744,10750-10752,10755,10759,10770,10775-10776,10813,10819 via svnmerge from 
  https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-bhy
................


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10837 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2008-09-12 10:51:51 +00:00

929 lines
25 KiB
C

/* -----------------------------------------------------------------------------
* See the LICENSE file for information on copyright, usage and redistribution
* of SWIG, and the README file for authors - http://www.swig.org/release.html.
*
* scanner.c
*
* SWIG tokenizer. This file is a wrapper around the generic C scanner
* found in Swig/scanner.c. Extra logic is added both to accomodate the
* bison-based grammar and certain peculiarities of C++ parsing (e.g.,
* operator overloading, typedef resolution, etc.). This code also splits
* C identifiers up into keywords and SWIG directives.
* ----------------------------------------------------------------------------- */
char cvsroot_cscanner_c[] = "$Id$";
#include "cparse.h"
#include "parser.h"
#include <string.h>
#include <ctype.h>
/* Scanner object */
static Scanner *scan = 0;
/* Global string containing C code. Used by the parser to grab code blocks */
DOHString *scanner_ccode = 0;
/* Error reporting/location information */
int cparse_line = 1;
String *cparse_file = 0;
int cparse_start_line = 0;
/* C++ mode */
int cparse_cplusplus = 0;
/* Private vars */
static int scan_init = 0;
static int num_brace = 0;
static int last_brace = 0;
static int last_id = 0;
static int rename_active = 0;
static int expanding_macro = 0;
static int follow_locators = 0;
/* -----------------------------------------------------------------------------
* Swig_cparse_cplusplus()
* ----------------------------------------------------------------------------- */
void Swig_cparse_cplusplus(int v) {
cparse_cplusplus = v;
}
/* ----------------------------------------------------------------------
* locator()
*
* Support for locator strings. These are strings of the form
* @SWIG:filename,line,id@ emitted by the SWIG preprocessor. They
* are primarily used for macro line number reporting
* ---------------------------------------------------------------------- */
typedef struct Locator {
String *filename;
int line_number;
struct Locator *next;
} Locator;
static Locator *locs = 0;
/* we just use the locator to mark when active/deactive the linecounting */
static void scanner_locator(String *loc) {
if (!follow_locators) {
if (Equal(loc, "/*@SWIG@*/")) {
/* End locator. */
if (expanding_macro)
--expanding_macro;
} else {
/* Begin locator. */
++expanding_macro;
}
/* Freeze line number processing in Scanner */
Scanner_freeze_line(scan,expanding_macro);
} else {
int c;
Locator *l;
Seek(loc, 7, SEEK_SET);
c = Getc(loc);
if (c == '@') {
/* Empty locator. We pop the last location off */
if (locs) {
Scanner_set_location(scan,locs->filename,locs->line_number);
cparse_file = locs->filename;
cparse_line = locs->line_number;
l = locs->next;
free(locs);
locs = l;
}
return;
}
/* We're going to push a new location */
l = (Locator *) malloc(sizeof(Locator));
l->filename = cparse_file;
l->line_number = cparse_line;
l->next = locs;
locs = l;
/* Now, parse the new location out of the locator string */
{
String *fn = NewStringEmpty();
/* Putc(c, fn); */
while ((c = Getc(loc)) != EOF) {
if ((c == '@') || (c == ','))
break;
Putc(c, fn);
}
cparse_file = Swig_copy_string(Char(fn));
Clear(fn);
cparse_line = 1;
/* Get the line number */
while ((c = Getc(loc)) != EOF) {
if ((c == '@') || (c == ','))
break;
Putc(c, fn);
}
cparse_line = atoi(Char(fn));
Clear(fn);
/* Get the rest of it */
while ((c = Getc(loc)) != EOF) {
if (c == '@')
break;
Putc(c, fn);
}
/* Printf(stderr,"location: %s:%d\n",cparse_file,cparse_line); */
Scanner_set_location(scan,cparse_file,cparse_line);
Delete(fn);
}
}
}
void Swig_cparse_follow_locators(int v) {
follow_locators = v;
}
/* ----------------------------------------------------------------------------
* scanner_init()
*
* Initialize buffers
* ------------------------------------------------------------------------- */
void scanner_init() {
scan = NewScanner();
Scanner_idstart(scan,"%");
scan_init = 1;
scanner_ccode = NewStringEmpty();
}
/* ----------------------------------------------------------------------------
* scanner_file(DOHFile *f)
*
* Start reading from new file
* ------------------------------------------------------------------------- */
void scanner_file(DOHFile * f) {
if (!scan_init) scanner_init();
Scanner_clear(scan);
Scanner_push(scan,f);
}
/* ----------------------------------------------------------------------------
* start_inline(char *text, int line)
*
* Take a chunk of text and recursively feed it back into the scanner. Used
* by the %inline directive.
* ------------------------------------------------------------------------- */
void start_inline(char *text, int line) {
String *stext = NewString(text);
Seek(stext,0,SEEK_SET);
Setfile(stext,cparse_file);
Setline(stext,line);
Scanner_push(scan,stext);
Delete(stext);
}
/* -----------------------------------------------------------------------------
* skip_balanced()
*
* Skips a piece of code enclosed in begin/end symbols such as '{...}' or
* (...). Ignores symbols inside comments or strings.
* ----------------------------------------------------------------------------- */
void skip_balanced(int startchar, int endchar) {
Clear(scanner_ccode);
if (Scanner_skip_balanced(scan,startchar,endchar) < 0) {
Swig_error(Scanner_file(scan),Scanner_errline(scan), "Missing '%c'. Reached end of input.\n", endchar);
return;
}
cparse_line = Scanner_line(scan);
cparse_file = Scanner_file(scan);
Append(scanner_ccode, Scanner_text(scan));
if (endchar == '}')
num_brace--;
return;
}
/* ----------------------------------------------------------------------------
* void skip_decl(void)
*
* This tries to skip over an entire declaration. For example
*
* friend ostream& operator<<(ostream&, const char *s);
*
* or
* friend ostream& operator<<(ostream&, const char *s) { };
*
* ------------------------------------------------------------------------- */
void skip_decl(void) {
int tok;
int done = 0;
int start_line = Scanner_line(scan);
while (!done) {
tok = Scanner_token(scan);
if (tok == 0) {
if (!Swig_error_count()) {
Swig_error(cparse_file, start_line, "Missing semicolon. Reached end of input.\n");
}
return;
}
if (tok == SWIG_TOKEN_LBRACE) {
if (Scanner_skip_balanced(scan,'{','}') < 0) {
Swig_error(cparse_file, start_line, "Missing '}'. Reached end of input.\n");
}
break;
}
if (tok == SWIG_TOKEN_SEMI) {
done = 1;
}
}
cparse_file = Scanner_file(scan);
cparse_line = Scanner_line(scan);
}
/* ----------------------------------------------------------------------------
* int yylook()
*
* Lexical scanner.
* ------------------------------------------------------------------------- */
int yylook(void) {
int tok = 0;
while (1) {
if ((tok = Scanner_token(scan)) == 0)
return 0;
if (tok == SWIG_TOKEN_ERROR) {
Swig_error(Scanner_file(scan), Scanner_errline(scan), Scanner_errmsg(scan));
continue;
}
cparse_start_line = Scanner_start_line(scan);
cparse_line = Scanner_line(scan);
cparse_file = Scanner_file(scan);
switch(tok) {
case SWIG_TOKEN_ID:
return ID;
case SWIG_TOKEN_LPAREN:
return LPAREN;
case SWIG_TOKEN_RPAREN:
return RPAREN;
case SWIG_TOKEN_SEMI:
return SEMI;
case SWIG_TOKEN_COMMA:
return COMMA;
case SWIG_TOKEN_STAR:
return STAR;
case SWIG_TOKEN_RBRACE:
num_brace--;
if (num_brace < 0) {
Swig_error(cparse_file, cparse_line, "Syntax error. Extraneous '}'\n");
num_brace = 0;
} else {
return RBRACE;
}
break;
case SWIG_TOKEN_LBRACE:
last_brace = num_brace;
num_brace++;
return LBRACE;
case SWIG_TOKEN_EQUAL:
return EQUAL;
case SWIG_TOKEN_EQUALTO:
return EQUALTO;
case SWIG_TOKEN_PLUS:
return PLUS;
case SWIG_TOKEN_MINUS:
return MINUS;
case SWIG_TOKEN_SLASH:
return SLASH;
case SWIG_TOKEN_AND:
return AND;
case SWIG_TOKEN_LAND:
return LAND;
case SWIG_TOKEN_OR:
return OR;
case SWIG_TOKEN_LOR:
return LOR;
case SWIG_TOKEN_XOR:
return XOR;
case SWIG_TOKEN_NOT:
return NOT;
case SWIG_TOKEN_LNOT:
return LNOT;
case SWIG_TOKEN_NOTEQUAL:
return NOTEQUALTO;
case SWIG_TOKEN_LBRACKET:
return LBRACKET;
case SWIG_TOKEN_RBRACKET:
return RBRACKET;
case SWIG_TOKEN_QUESTION:
return QUESTIONMARK;
case SWIG_TOKEN_LESSTHAN:
return LESSTHAN;
case SWIG_TOKEN_LTEQUAL:
return LESSTHANOREQUALTO;
case SWIG_TOKEN_LSHIFT:
return LSHIFT;
case SWIG_TOKEN_GREATERTHAN:
return GREATERTHAN;
case SWIG_TOKEN_GTEQUAL:
return GREATERTHANOREQUALTO;
case SWIG_TOKEN_RSHIFT:
return RSHIFT;
case SWIG_TOKEN_PERIOD:
return PERIOD;
case SWIG_TOKEN_MODULO:
return MODULO;
case SWIG_TOKEN_COLON:
return COLON;
case SWIG_TOKEN_DCOLONSTAR:
return DSTAR;
case SWIG_TOKEN_DCOLON:
{
int nexttok = Scanner_token(scan);
if (nexttok == SWIG_TOKEN_STAR) {
return DSTAR;
} else if (nexttok == SWIG_TOKEN_NOT) {
return DCNOT;
} else {
Scanner_pushtoken(scan,nexttok,Scanner_text(scan));
if (!last_id) {
scanner_next_token(DCOLON);
return NONID;
} else {
return DCOLON;
}
}
}
break;
/* Look for multi-character sequences */
case SWIG_TOKEN_RSTRING:
yylval.type = NewString(Scanner_text(scan));
return TYPE_RAW;
case SWIG_TOKEN_STRING:
yylval.id = Swig_copy_string(Char(Scanner_text(scan)));
return STRING;
case SWIG_TOKEN_CHAR:
yylval.str = NewString(Scanner_text(scan));
if (Len(yylval.str) == 0) {
Swig_error(cparse_file, cparse_line, "Empty character constant\n");
Printf(stdout,"%d\n", Len(Scanner_text(scan)));
}
return CHARCONST;
/* Numbers */
case SWIG_TOKEN_INT:
return NUM_INT;
case SWIG_TOKEN_UINT:
return NUM_UNSIGNED;
case SWIG_TOKEN_LONG:
return NUM_LONG;
case SWIG_TOKEN_ULONG:
return NUM_ULONG;
case SWIG_TOKEN_LONGLONG:
return NUM_LONGLONG;
case SWIG_TOKEN_ULONGLONG:
return NUM_ULONGLONG;
case SWIG_TOKEN_DOUBLE:
case SWIG_TOKEN_FLOAT:
return NUM_FLOAT;
case SWIG_TOKEN_POUND:
Scanner_skip_line(scan);
yylval.id = Swig_copy_string(Char(Scanner_text(scan)));
return POUND;
break;
case SWIG_TOKEN_CODEBLOCK:
yylval.str = NewString(Scanner_text(scan));
return HBLOCK;
case SWIG_TOKEN_COMMENT:
{
String *cmt = Scanner_text(scan);
char *loc = Char(cmt);
if ((strncmp(loc,"/*@SWIG",7) == 0) && (loc[Len(cmt)-3] == '@')) {
scanner_locator(cmt);
}
if (strncmp(loc, "/**<", 4) == 0 || strncmp(loc, "///<", 4) == 0||strncmp(loc, "/*!<", 4) == 0||strncmp(loc, "//!<", 4) == 0) {
printf("Doxygen Post Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc);
yylval.str = NewString(loc);
return DOXYGENPOSTSTRING;
}
if (strncmp(loc, "/**", 3) == 0 || strncmp(loc, "///", 3) == 0||strncmp(loc, "/*!", 3) == 0||strncmp(loc, "//!", 3) == 0) {
printf("Doxygen Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc);
yylval.str = NewString(loc);
return DOXYGENSTRING;
}
}
break;
case SWIG_TOKEN_ENDLINE:
break;
case SWIG_TOKEN_BACKSLASH:
break;
default:
Swig_error(cparse_file, cparse_line, "Illegal token '%s'.\n", Scanner_text(scan));
return (ILLEGAL);
}
}
}
static int check_typedef = 0;
void scanner_set_location(String_or_char *file, int line) {
Scanner_set_location(scan,file,line-1);
}
void scanner_check_typedef() {
check_typedef = 1;
}
void scanner_ignore_typedef() {
check_typedef = 0;
}
void scanner_last_id(int x) {
last_id = x;
}
void scanner_clear_rename() {
rename_active = 0;
}
/* Used to push a ficticious token into the scanner */
static int next_token = 0;
void scanner_next_token(int tok) {
next_token = tok;
}
/* ----------------------------------------------------------------------------
* int yylex()
*
* Gets the lexene and returns tokens.
* ------------------------------------------------------------------------- */
int yylex(void) {
int l;
char *yytext;
if (!scan_init) {
scanner_init();
}
if (next_token) {
l = next_token;
next_token = 0;
return l;
}
l = yylook();
/* Printf(stdout, "%s:%d:::%d: '%s'\n", cparse_file, cparse_line, l, Scanner_text(scan)); */
if (l == NONID) {
last_id = 1;
} else {
last_id = 0;
}
/* We got some sort of non-white space object. We set the start_line
variable unless it has already been set */
if (!cparse_start_line) {
cparse_start_line = cparse_line;
}
/* Copy the lexene */
switch (l) {
case NUM_INT:
case NUM_FLOAT:
case NUM_ULONG:
case NUM_LONG:
case NUM_UNSIGNED:
case NUM_LONGLONG:
case NUM_ULONGLONG:
if (l == NUM_INT)
yylval.dtype.type = T_INT;
if (l == NUM_FLOAT)
yylval.dtype.type = T_DOUBLE;
if (l == NUM_ULONG)
yylval.dtype.type = T_ULONG;
if (l == NUM_LONG)
yylval.dtype.type = T_LONG;
if (l == NUM_UNSIGNED)
yylval.dtype.type = T_UINT;
if (l == NUM_LONGLONG)
yylval.dtype.type = T_LONGLONG;
if (l == NUM_ULONGLONG)
yylval.dtype.type = T_ULONGLONG;
yylval.dtype.val = NewString(Scanner_text(scan));
yylval.dtype.bitfield = 0;
yylval.dtype.throws = 0;
return (l);
case ID:
yytext = Char(Scanner_text(scan));
if (yytext[0] != '%') {
/* Look for keywords now */
if (strcmp(yytext, "int") == 0) {
yylval.type = NewSwigType(T_INT);
return (TYPE_INT);
}
if (strcmp(yytext, "double") == 0) {
yylval.type = NewSwigType(T_DOUBLE);
return (TYPE_DOUBLE);
}
if (strcmp(yytext, "void") == 0) {
yylval.type = NewSwigType(T_VOID);
return (TYPE_VOID);
}
if (strcmp(yytext, "char") == 0) {
yylval.type = NewSwigType(T_CHAR);
return (TYPE_CHAR);
}
if (strcmp(yytext, "wchar_t") == 0) {
yylval.type = NewSwigType(T_WCHAR);
return (TYPE_WCHAR);
}
if (strcmp(yytext, "short") == 0) {
yylval.type = NewSwigType(T_SHORT);
return (TYPE_SHORT);
}
if (strcmp(yytext, "long") == 0) {
yylval.type = NewSwigType(T_LONG);
return (TYPE_LONG);
}
if (strcmp(yytext, "float") == 0) {
yylval.type = NewSwigType(T_FLOAT);
return (TYPE_FLOAT);
}
if (strcmp(yytext, "signed") == 0) {
yylval.type = NewSwigType(T_INT);
return (TYPE_SIGNED);
}
if (strcmp(yytext, "unsigned") == 0) {
yylval.type = NewSwigType(T_UINT);
return (TYPE_UNSIGNED);
}
if (strcmp(yytext, "bool") == 0) {
yylval.type = NewSwigType(T_BOOL);
return (TYPE_BOOL);
}
/* Non ISO (Windows) C extensions */
if (strcmp(yytext, "__int8") == 0) {
yylval.type = NewString(yytext);
return (TYPE_NON_ISO_INT8);
}
if (strcmp(yytext, "__int16") == 0) {
yylval.type = NewString(yytext);
return (TYPE_NON_ISO_INT16);
}
if (strcmp(yytext, "__int32") == 0) {
yylval.type = NewString(yytext);
return (TYPE_NON_ISO_INT32);
}
if (strcmp(yytext, "__int64") == 0) {
yylval.type = NewString(yytext);
return (TYPE_NON_ISO_INT64);
}
/* C++ keywords */
if (cparse_cplusplus) {
if (strcmp(yytext, "and") == 0)
return (LAND);
if (strcmp(yytext, "or") == 0)
return (LOR);
if (strcmp(yytext, "not") == 0)
return (LNOT);
if (strcmp(yytext, "class") == 0)
return (CLASS);
if (strcmp(yytext, "private") == 0)
return (PRIVATE);
if (strcmp(yytext, "public") == 0)
return (PUBLIC);
if (strcmp(yytext, "protected") == 0)
return (PROTECTED);
if (strcmp(yytext, "friend") == 0)
return (FRIEND);
if (strcmp(yytext, "virtual") == 0)
return (VIRTUAL);
if (strcmp(yytext, "operator") == 0) {
int nexttok;
String *s = NewString("operator ");
/* If we have an operator, we have to collect the operator symbol and attach it to
the operator identifier. To do this, we need to scan ahead by several tokens.
Cases include:
(1) If the next token is an operator as determined by Scanner_isoperator(),
it means that the operator applies to one of the standard C++ mathematical,
assignment, or logical operator symbols (e.g., '+','<=','==','&', etc.)
In this case, we merely append the symbol text to the operator string above.
(2) If the next token is (, we look for ). This is operator ().
(3) If the next token is [, we look for ]. This is operator [].
(4) If the next token is an identifier. The operator is possibly a conversion operator.
(a) Must check for special case new[] and delete[]
Error handling is somewhat tricky here. We'll try to back out gracefully if we can.
*/
nexttok = Scanner_token(scan);
if (Scanner_isoperator(nexttok)) {
/* One of the standard C/C++ symbolic operators */
Append(s,Scanner_text(scan));
yylval.str = s;
return OPERATOR;
} else if (nexttok == SWIG_TOKEN_LPAREN) {
/* Function call operator. The next token MUST be a RPAREN */
nexttok = Scanner_token(scan);
if (nexttok != SWIG_TOKEN_RPAREN) {
Swig_error(Scanner_file(scan),Scanner_line(scan),"Syntax error. Bad operator name.\n");
} else {
Append(s,"()");
yylval.str = s;
return OPERATOR;
}
} else if (nexttok == SWIG_TOKEN_LBRACKET) {
/* Array access operator. The next token MUST be a RBRACKET */
nexttok = Scanner_token(scan);
if (nexttok != SWIG_TOKEN_RBRACKET) {
Swig_error(Scanner_file(scan),Scanner_line(scan),"Syntax error. Bad operator name.\n");
} else {
Append(s,"[]");
yylval.str = s;
return OPERATOR;
}
} else if (nexttok == SWIG_TOKEN_ID) {
/* We have an identifier. This could be any number of things. It could be a named version of
an operator (e.g., 'and_eq') or it could be a conversion operator. To deal with this, we're
going to read tokens until we encounter a ( or ;. Some care is needed for formatting. */
int needspace = 1;
int termtoken = 0;
const char *termvalue = 0;
Append(s,Scanner_text(scan));
while (1) {
nexttok = Scanner_token(scan);
if (nexttok <= 0) {
Swig_error(Scanner_file(scan),Scanner_line(scan),"Syntax error. Bad operator name.\n");
}
if (nexttok == SWIG_TOKEN_LPAREN) {
termtoken = SWIG_TOKEN_LPAREN;
termvalue = "(";
break;
} else if (nexttok == SWIG_TOKEN_CODEBLOCK) {
termtoken = SWIG_TOKEN_CODEBLOCK;
termvalue = Scanner_text(scan);
break;
} else if (nexttok == SWIG_TOKEN_LBRACE) {
termtoken = SWIG_TOKEN_LBRACE;
termvalue = "{";
break;
} else if (nexttok == SWIG_TOKEN_SEMI) {
termtoken = SWIG_TOKEN_SEMI;
termvalue = ";";
break;
} else if (nexttok == SWIG_TOKEN_ID) {
if (needspace) {
Append(s," ");
}
Append(s,Scanner_text(scan));
} else {
Append(s,Scanner_text(scan));
needspace = 0;
}
}
yylval.str = s;
if (!rename_active) {
String *cs;
char *t = Char(s) + 9;
if (!((strcmp(t, "new") == 0)
|| (strcmp(t, "delete") == 0)
|| (strcmp(t, "new[]") == 0)
|| (strcmp(t, "delete[]") == 0)
|| (strcmp(t, "and") == 0)
|| (strcmp(t, "and_eq") == 0)
|| (strcmp(t, "bitand") == 0)
|| (strcmp(t, "bitor") == 0)
|| (strcmp(t, "compl") == 0)
|| (strcmp(t, "not") == 0)
|| (strcmp(t, "not_eq") == 0)
|| (strcmp(t, "or") == 0)
|| (strcmp(t, "or_eq") == 0)
|| (strcmp(t, "xor") == 0)
|| (strcmp(t, "xor_eq") == 0)
)) {
/* retract(strlen(t)); */
/* The operator is a conversion operator. In order to deal with this, we need to feed the
type information back into the parser. For now this is a hack. Needs to be cleaned up later. */
cs = NewString(t);
if (termtoken) Append(cs,termvalue);
Seek(cs,0,SEEK_SET);
Setline(cs,cparse_line);
Setfile(cs,cparse_file);
Scanner_push(scan,cs);
Delete(cs);
return COPERATOR;
}
}
if (termtoken)
Scanner_pushtoken(scan, termtoken, termvalue);
return (OPERATOR);
}
}
if (strcmp(yytext, "throw") == 0)
return (THROW);
if (strcmp(yytext, "try") == 0)
return (yylex());
if (strcmp(yytext, "catch") == 0)
return (CATCH);
if (strcmp(yytext, "inline") == 0)
return (yylex());
if (strcmp(yytext, "mutable") == 0)
return (yylex());
if (strcmp(yytext, "explicit") == 0)
return (EXPLICIT);
if (strcmp(yytext, "export") == 0)
return (yylex());
if (strcmp(yytext, "typename") == 0)
return (TYPENAME);
if (strcmp(yytext, "template") == 0) {
yylval.ivalue = cparse_line;
return (TEMPLATE);
}
if (strcmp(yytext, "delete") == 0) {
return (DELETE_KW);
}
if (strcmp(yytext, "using") == 0) {
return (USING);
}
if (strcmp(yytext, "namespace") == 0) {
return (NAMESPACE);
}
} else {
if (strcmp(yytext, "class") == 0) {
Swig_warning(WARN_PARSE_CLASS_KEYWORD, cparse_file, cparse_line, "class keyword used, but not in C++ mode.\n");
}
if (strcmp(yytext, "complex") == 0) {
yylval.type = NewSwigType(T_COMPLEX);
return (TYPE_COMPLEX);
}
if (strcmp(yytext, "restrict") == 0)
return (yylex());
}
/* Misc keywords */
if (strcmp(yytext, "extern") == 0)
return (EXTERN);
if (strcmp(yytext, "const") == 0)
return (CONST_QUAL);
if (strcmp(yytext, "static") == 0)
return (STATIC);
if (strcmp(yytext, "struct") == 0)
return (STRUCT);
if (strcmp(yytext, "union") == 0)
return (UNION);
if (strcmp(yytext, "enum") == 0)
return (ENUM);
if (strcmp(yytext, "sizeof") == 0)
return (SIZEOF);
if (strcmp(yytext, "typedef") == 0) {
yylval.ivalue = 0;
return (TYPEDEF);
}
/* Ignored keywords */
if (strcmp(yytext, "volatile") == 0)
return (VOLATILE);
if (strcmp(yytext, "register") == 0)
return (REGISTER);
if (strcmp(yytext, "inline") == 0)
return (yylex());
/* SWIG directives */
} else {
if (strcmp(yytext, "%module") == 0)
return (MODULE);
if (strcmp(yytext, "%insert") == 0)
return (INSERT);
if (strcmp(yytext, "%name") == 0)
return (NAME);
if (strcmp(yytext, "%rename") == 0) {
rename_active = 1;
return (RENAME);
}
if (strcmp(yytext, "%namewarn") == 0) {
rename_active = 1;
return (NAMEWARN);
}
if (strcmp(yytext, "%includefile") == 0)
return (INCLUDE);
if (strcmp(yytext, "%val") == 0) {
Swig_warning(WARN_DEPRECATED_VAL, cparse_file, cparse_line, "%%val directive deprecated (ignored).\n");
return (yylex());
}
if (strcmp(yytext, "%out") == 0) {
Swig_warning(WARN_DEPRECATED_OUT, cparse_file, cparse_line, "%%out directive deprecated (ignored).\n");
return (yylex());
}
if (strcmp(yytext, "%constant") == 0)
return (CONSTANT);
if (strcmp(yytext, "%typedef") == 0) {
yylval.ivalue = 1;
return (TYPEDEF);
}
if (strcmp(yytext, "%native") == 0)
return (NATIVE);
if (strcmp(yytext, "%pragma") == 0)
return (PRAGMA);
if (strcmp(yytext, "%extend") == 0)
return (EXTEND);
if (strcmp(yytext, "%fragment") == 0)
return (FRAGMENT);
if (strcmp(yytext, "%inline") == 0)
return (INLINE);
if (strcmp(yytext, "%typemap") == 0)
return (TYPEMAP);
if (strcmp(yytext, "%feature") == 0) {
/* The rename_active indicates we don't need the information of the
* following function's return type. This applied for %rename, so do
* %feature.
*/
rename_active = 1;
return (FEATURE);
}
if (strcmp(yytext, "%except") == 0)
return (EXCEPT);
if (strcmp(yytext, "%importfile") == 0)
return (IMPORT);
if (strcmp(yytext, "%echo") == 0)
return (ECHO);
if (strcmp(yytext, "%apply") == 0)
return (APPLY);
if (strcmp(yytext, "%clear") == 0)
return (CLEAR);
if (strcmp(yytext, "%types") == 0)
return (TYPES);
if (strcmp(yytext, "%parms") == 0)
return (PARMS);
if (strcmp(yytext, "%varargs") == 0)
return (VARARGS);
if (strcmp(yytext, "%template") == 0) {
return (SWIGTEMPLATE);
}
if (strcmp(yytext, "%warn") == 0)
return (WARN);
}
/* Have an unknown identifier, as a last step, we'll do a typedef lookup on it. */
/* Need to fix this */
if (check_typedef) {
if (SwigType_istypedef(yytext)) {
yylval.type = NewString(yytext);
return (TYPE_TYPEDEF);
}
}
yylval.id = Swig_copy_string(yytext);
last_id = 1;
return (ID);
case POUND:
return yylex();
case SWIG_TOKEN_COMMENT:
return yylex();
default:
return (l);
}
}