Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmCommandArgumentLexer.in.l
blobf0686032f917e58305d3d75875794bd5da66039c
1 %{
2 /*=========================================================================
4   Program:   CMake - Cross-Platform Makefile Generator
5   Module:    $RCSfile: cmCommandArgumentLexer.in.l,v $
6   Language:  C++
7   Date:      $Date: 2007/06/05 13:19:27 $
8   Version:   $Revision: 1.10 $
10   Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
11   See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
17 =========================================================================*/
20 This file must be translated to C and modified to build everywhere.
22 Run flex like this:
24   flex --prefix=cmCommandArgument_yy --header-file=cmCommandArgumentLexer.h -ocmCommandArgumentLexer.cxx cmCommandArgumentLexer.in.l
26 Modify cmCommandArgumentLexer.cxx:
27   - add #include "cmStandardIncludes.h" to top of file
28   - remove TABs
29   - remove "yyscanner" argument from these methods:
30       yy_fatal_error, cmCommandArgument_yyalloc, cmCommandArgument_yyrealloc, cmCommandArgument_yyfree
31   - remove all YY_BREAK lines occurring right after return statements
32   - change while ( 1 ) to for(;;)
34 Modify cmCommandArgumentLexer.h:
35   - remove TABs
36   - remove the yy_init_globals function
37   - remove the block that includes unistd.h
38   - remove #line directives (avoids bogus warning on old Sun)
42 #include "cmStandardLexer.h"
44 #include "cmCommandArgumentParserHelper.h"
46 /* Replace the lexer input function.  */
47 #undef YY_INPUT
48 #define YY_INPUT(buf, result, max_size) \
49   { result = yyextra->LexInput(buf, max_size); }
51 /* Include the set of tokens from the parser.  */
52 #include "cmCommandArgumentParserTokens.h"
54 /*--------------------------------------------------------------------------*/
57 %option reentrant
58 %option noyywrap
59 %pointer
60 %s ESCAPES
61 %s NOESCAPES
65 \$[A-Za-z0-9/_.+-]+\{ { 
66   //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
67   yyextra->AllocateParserType(yylvalp, yytext+1, strlen(yytext)-2); 
68   return cal_NCURLY; 
69
71 @[A-Za-z0-9/_.+-]+@ { 
72   //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
73   yyextra->AllocateParserType(yylvalp, yytext+1, strlen(yytext)-2); 
74   return cal_ATNAME; 
75
77 "${" {
78   //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
79   //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); 
80   yylvalp->str = yyextra->DCURLYVariable;
81   return cal_DCURLY;
84 "}" {
85   //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
86   //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); 
87   yylvalp->str = yyextra->RCURLYVariable;
88   return cal_RCURLY;
91 "@" {
92   //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
93   //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); 
94   yylvalp->str = yyextra->ATVariable;
95   return cal_AT;
98 [A-Za-z0-9/_.+-]+ { 
99   //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
100   yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); 
101   return cal_NAME; 
104 <ESCAPES>\\. {
105   if ( !yyextra->HandleEscapeSymbol(yylvalp, *(yytext+1)) )
106     {
107     return cal_ERROR;
108     }
109   return cal_SYMBOL; 
112 [^\${}\\@]+ { 
113   //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
114   yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); 
115   return cal_SYMBOL; 
118 "$" {
119   //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); 
120   yylvalp->str = yyextra->DOLLARVariable;
121   return cal_DOLLAR; 
124 "{" {
125   //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); 
126   yylvalp->str = yyextra->LCURLYVariable;
127   return cal_LCURLY; 
130 <ESCAPES>"\\" {
131   //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); 
132   yylvalp->str = yyextra->BSLASHVariable;
133   return cal_BSLASH; 
136 <NOESCAPES>"\\" {
137   //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
138   yylvalp->str = yyextra->BSLASHVariable;
139   return cal_SYMBOL;
144 /*--------------------------------------------------------------------------*/
145 void cmCommandArgument_SetupEscapes(yyscan_t yyscanner, bool noEscapes)
147   /* Hack into the internal flex-generated scanner to set the state.  */
148   struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
149   if(noEscapes)
150     {
151     BEGIN(NOESCAPES);
152     }
153   else
154     {
155     BEGIN(ESCAPES);
156     }