2005-01-29 00:56:12 +03:00
|
|
|
%{
|
2016-09-27 22:01:08 +03:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2005-01-29 00:56:12 +03:00
|
|
|
/*
|
|
|
|
|
|
|
|
This file must be translated to C and modified to build everywhere.
|
|
|
|
|
|
|
|
Run flex like this:
|
|
|
|
|
|
|
|
flex --prefix=cmDependsJava_yy --header-file=cmDependsJavaLexer.h -ocmDependsJavaLexer.cxx cmDependsJavaLexer.in.l
|
|
|
|
|
2006-08-08 22:00:28 +04:00
|
|
|
Modify cmDependsJavaLexer.c:
|
2005-01-29 00:56:12 +03:00
|
|
|
- remove TABs
|
2013-06-28 23:21:35 +04:00
|
|
|
- remove use of the 'register' storage class specifier
|
2005-01-29 00:56:12 +03:00
|
|
|
- remove "yyscanner" argument from these methods:
|
2006-08-08 22:00:28 +04:00
|
|
|
yy_fatal_error, cmDependsJava_yyalloc, cmDependsJava_yyrealloc, cmDependsJava_yyfree
|
2005-01-29 00:56:12 +03:00
|
|
|
- remove all YY_BREAK lines occurring right after return statements
|
2005-05-03 23:19:34 +04:00
|
|
|
- change while ( 1 ) to for(;;)
|
2005-01-29 00:56:12 +03:00
|
|
|
|
|
|
|
Modify cmDependsJavaLexer.h:
|
|
|
|
- remove TABs
|
|
|
|
- remove the yy_init_globals function
|
|
|
|
- remove the block that includes unistd.h
|
2005-02-01 18:44:34 +03:00
|
|
|
- remove #line directives (avoids bogus warning on old Sun)
|
2005-01-29 00:56:12 +03:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
2006-08-08 22:00:28 +04:00
|
|
|
#include "cmStandardLexer.h"
|
2005-01-29 00:56:12 +03:00
|
|
|
|
2006-08-08 22:00:28 +04:00
|
|
|
#include "cmDependsJavaParserHelper.h"
|
2005-01-29 00:56:12 +03:00
|
|
|
|
|
|
|
/* Replace the lexer input function. */
|
|
|
|
#undef YY_INPUT
|
|
|
|
#define YY_INPUT(buf, result, max_size) \
|
|
|
|
{ result = yyextra->LexInput(buf, max_size); }
|
|
|
|
|
|
|
|
/* Include the set of tokens from the parser. */
|
|
|
|
#include "cmDependsJavaParserTokens.h"
|
|
|
|
|
|
|
|
#define KEYWORD yylvalp->str = 0
|
|
|
|
#define SYMBOL yylvalp->str = 0
|
|
|
|
#define PRIMITIVE yylvalp->str = 0
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
%}
|
|
|
|
|
|
|
|
%option reentrant
|
|
|
|
%option noyywrap
|
|
|
|
%pointer
|
|
|
|
|
|
|
|
%x comment
|
|
|
|
%x string
|
|
|
|
|
|
|
|
%%
|
|
|
|
"/*" { BEGIN(comment); }
|
|
|
|
<comment>"*/" { BEGIN(INITIAL); }
|
|
|
|
<comment>.|\n {}
|
|
|
|
|
|
|
|
\" { BEGIN(string); }
|
2005-01-29 01:43:57 +03:00
|
|
|
<string>\" { BEGIN(INITIAL); return jp_STRINGLITERAL; }
|
2005-01-29 00:56:12 +03:00
|
|
|
<string>. {}
|
|
|
|
|
2005-01-29 01:43:57 +03:00
|
|
|
abstract { KEYWORD; return jp_ABSTRACT; }
|
|
|
|
assert { KEYWORD; return jp_ASSERT; }
|
|
|
|
boolean { KEYWORD; return jp_BOOLEAN_TYPE; }
|
|
|
|
break { KEYWORD; return jp_BREAK; }
|
|
|
|
byte { KEYWORD; return jp_BYTE_TYPE; }
|
|
|
|
case { KEYWORD; return jp_CASE; }
|
|
|
|
catch { KEYWORD; return jp_CATCH; }
|
|
|
|
char { KEYWORD; return jp_CHAR_TYPE; }
|
|
|
|
class { KEYWORD; return jp_CLASS; }
|
|
|
|
continue { KEYWORD; return jp_CONTINUE; }
|
|
|
|
default { KEYWORD; return jp_DEFAULT; }
|
|
|
|
do { KEYWORD; return jp_DO; }
|
|
|
|
double { KEYWORD; return jp_DOUBLE_TYPE; }
|
|
|
|
else { KEYWORD; return jp_ELSE; }
|
|
|
|
extends { KEYWORD; return jp_EXTENDS; }
|
|
|
|
final { KEYWORD; return jp_FINAL; }
|
|
|
|
finally { KEYWORD; return jp_FINALLY; }
|
|
|
|
float { KEYWORD; return jp_FLOAT_TYPE; }
|
|
|
|
for { KEYWORD; return jp_FOR; }
|
|
|
|
if { KEYWORD; return jp_IF; }
|
|
|
|
implements { KEYWORD; return jp_IMPLEMENTS; }
|
|
|
|
import { KEYWORD; return jp_IMPORT; }
|
|
|
|
instanceof { KEYWORD; return jp_INSTANCEOF; }
|
|
|
|
int { KEYWORD; return jp_INT_TYPE; }
|
|
|
|
interface { KEYWORD; return jp_INTERFACE; }
|
|
|
|
long { KEYWORD; return jp_LONG_TYPE; }
|
|
|
|
native { KEYWORD; return jp_NATIVE; }
|
|
|
|
new { KEYWORD; return jp_NEW; }
|
|
|
|
package { KEYWORD; return jp_PACKAGE; }
|
|
|
|
private { KEYWORD; return jp_PRIVATE; }
|
|
|
|
protected { KEYWORD; return jp_PROTECTED; }
|
|
|
|
public { KEYWORD; return jp_PUBLIC; }
|
|
|
|
return { KEYWORD; return jp_RETURN; }
|
|
|
|
short { KEYWORD; return jp_SHORT_TYPE; }
|
|
|
|
static { KEYWORD; return jp_STATIC; }
|
|
|
|
strictfp { KEYWORD; return jp_STRICTFP; }
|
|
|
|
super { KEYWORD; return jp_SUPER; }
|
|
|
|
switch { KEYWORD; return jp_SWITCH; }
|
|
|
|
synchronized { KEYWORD; return jp_SYNCHRONIZED; }
|
|
|
|
this { KEYWORD; return jp_THIS; }
|
|
|
|
throw { KEYWORD; return jp_THROW; }
|
|
|
|
throws { KEYWORD; return jp_THROWS; }
|
|
|
|
transient { KEYWORD; return jp_TRANSIENT; }
|
|
|
|
try { KEYWORD; return jp_TRY; }
|
|
|
|
void { KEYWORD; return jp_VOID; }
|
|
|
|
volatile { KEYWORD; return jp_VOLATILE; }
|
|
|
|
while { KEYWORD; return jp_WHILE; }
|
|
|
|
|
|
|
|
(true|false) { PRIMITIVE; return jp_BOOLEANLITERAL; }
|
|
|
|
\'([^\\]|\\.|\\u[0-9a-fA-F]*|\\[0-7]*)\' { PRIMITIVE; return jp_CHARACTERLITERAL; }
|
|
|
|
(0|[0-9]+)[lL]? { PRIMITIVE; return jp_DECIMALINTEGERLITERAL; }
|
|
|
|
([0-9]+\.[0-9]*|\.[0-9]+|[0-9]+)([eE][+\-]?[0-9]+)?[fFdD]? { PRIMITIVE; return jp_FLOATINGPOINTLITERAL; }
|
|
|
|
0[xX][0-9a-fA-F]+[lL]? { PRIMITIVE; return jp_HEXINTEGERLITERAL; }
|
|
|
|
null { PRIMITIVE; return jp_NULLLITERAL; }
|
|
|
|
|
|
|
|
"&" { SYMBOL; return jp_AND; }
|
|
|
|
"&&" { SYMBOL; return jp_ANDAND; }
|
|
|
|
"&=" { SYMBOL; return jp_ANDEQUALS; }
|
|
|
|
"\]" { SYMBOL; return jp_BRACKETEND; }
|
|
|
|
"\[" { SYMBOL; return jp_BRACKETSTART; }
|
|
|
|
"\^" { SYMBOL; return jp_CARROT; }
|
|
|
|
"\^=" { SYMBOL; return jp_CARROTEQUALS; }
|
|
|
|
":" { SYMBOL; return jp_COLON; }
|
|
|
|
"," { SYMBOL; return jp_COMMA; }
|
|
|
|
"}" { SYMBOL; return jp_CURLYEND; }
|
|
|
|
"{" { SYMBOL; return jp_CURLYSTART; }
|
|
|
|
"/" { SYMBOL; return jp_DIVIDE; }
|
|
|
|
"/=" { SYMBOL; return jp_DIVIDEEQUALS; }
|
|
|
|
"\$" { SYMBOL; return jp_DOLLAR; }
|
|
|
|
"\." { SYMBOL; return jp_DOT; }
|
|
|
|
"=" { SYMBOL; return jp_EQUALS; }
|
|
|
|
"==" { SYMBOL; return jp_EQUALSEQUALS; }
|
|
|
|
"\!" { SYMBOL; return jp_EXCLAMATION; }
|
|
|
|
"\!=" { SYMBOL; return jp_EXCLAMATIONEQUALS; }
|
|
|
|
">" { SYMBOL; return jp_GREATER; }
|
|
|
|
">=" { SYMBOL; return jp_GTEQUALS; }
|
|
|
|
">>" { SYMBOL; return jp_GTGT; }
|
|
|
|
">>=" { SYMBOL; return jp_GTGTEQUALS; }
|
|
|
|
">>>" { SYMBOL; return jp_GTGTGT; }
|
|
|
|
">>>=" { SYMBOL; return jp_GTGTGTEQUALS; }
|
|
|
|
"<<=" { SYMBOL; return jp_LESLESEQUALS; }
|
|
|
|
"<" { SYMBOL; return jp_LESSTHAN; }
|
|
|
|
"<=" { SYMBOL; return jp_LTEQUALS; }
|
|
|
|
"<<" { SYMBOL; return jp_LTLT; }
|
|
|
|
"-" { SYMBOL; return jp_MINUS; }
|
|
|
|
"-=" { SYMBOL; return jp_MINUSEQUALS; }
|
|
|
|
"--" { SYMBOL; return jp_MINUSMINUS; }
|
|
|
|
"\)" { SYMBOL; return jp_PAREEND; }
|
|
|
|
"\(" { SYMBOL; return jp_PARESTART; }
|
|
|
|
"%" { SYMBOL; return jp_PERCENT; }
|
|
|
|
"%=" { SYMBOL; return jp_PERCENTEQUALS; }
|
|
|
|
"\|" { SYMBOL; return jp_PIPE; }
|
|
|
|
"\|=" { SYMBOL; return jp_PIPEEQUALS; }
|
|
|
|
"\|\|" { SYMBOL; return jp_PIPEPIPE; }
|
|
|
|
"\+" { SYMBOL; return jp_PLUS; }
|
|
|
|
"\+=" { SYMBOL; return jp_PLUSEQUALS; }
|
|
|
|
"\+\+" { SYMBOL; return jp_PLUSPLUS; }
|
|
|
|
"\?" { SYMBOL; return jp_QUESTION; }
|
|
|
|
";" { SYMBOL; return jp_SEMICOL; }
|
|
|
|
"\~" { SYMBOL; return jp_TILDE; }
|
|
|
|
"\*" { SYMBOL; return jp_TIMES; }
|
|
|
|
"\*=" { SYMBOL; return jp_TIMESEQUALS; }
|
2005-01-29 00:56:12 +03:00
|
|
|
|
2012-08-13 21:42:58 +04:00
|
|
|
[a-z_A-Z][a-z_0-9A-Z]* {
|
|
|
|
yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
|
|
|
|
return jp_NAME;
|
2005-01-29 00:56:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
\/\/.*\n { }
|
|
|
|
[ \f\t\n\r] { }
|
2012-08-13 21:42:58 +04:00
|
|
|
. {
|
|
|
|
std::cerr << "Unknown character: " << yytext[0]
|
|
|
|
<< " (" << (int)yytext[0] << ")" << std::endl;
|
|
|
|
yyextra->Error("Unknown character");
|
|
|
|
return jp_ERROR;
|
2005-01-29 00:56:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
%%
|