diff -r c7c26511138f -r 360bd6b35136 bintools/rcomp/src/RCOMP.LEX --- a/bintools/rcomp/src/RCOMP.LEX Wed Jun 16 16:51:40 2010 +0300 +++ b/bintools/rcomp/src/RCOMP.LEX Wed Jun 23 16:56:47 2010 +0800 @@ -1,317 +1,302 @@ -%option yylineno -%{ -// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). -// All rights reserved. -// This component and the accompanying materials are made available -// under the terms of the License "Eclipse Public License v1.0" -// which accompanies this distribution, and is available -// at the URL "http://www.eclipse.org/legal/epl-v10.html". -// -// Initial Contributors: -// Nokia Corporation - initial contribution. -// -// Contributors: -// -// Description: -// RCOMPL.INL -// Generated from RCOMP.L - - -#include -#include -#include "main.h" -#include "structst.h" -#include "parser.h" -#include "localise.h" - -#define YY_SKIP_YYWRAP 1 -#define YY_NEVER_INTERACTIVE 1 -int yywrap(); -void yyerror(const char* string, ...); - -// Redefine YY_INPUT so we can parse binary data. -#undef YY_INPUT -#define YY_INPUT(buf, result, max_size) (result = new_yy_input(buf, max_size)) - -int new_yy_input(char *buf, int max_size) -{ - int result; - result = fread(buf, 1, max_size, yyin); - if (result == 0) - return YY_NULL; - - // check for utf8 (BOM) header in buf - for (int i = 0; i < result-3; i++) - { - if (buf[i] == 0xffffffef && buf[i+1] == 0xffffffbb && buf[i+2] == 0xffffffbf) - { - buf[i] = ' '; - buf[i+1] = ' '; - buf[i+2] = ' '; - } - } - return result; -} - -#include "rcomp.hpp" -#include "fileline.h" - -#define VALUE_LEN (1024*8) // must match sizeof(YYSTYPE.Value) -char buf[VALUE_LEN]; -char * pCh; -#define CHECK_APPEND(x) \ - if (pCh-buf==VALUE_LEN-1) { yyerror("string too long - %c ignored", (x)); } else {*pCh++ = (x); } - -int isCharLiteral; - -extern String InputBaseName; -extern FileLineManager* pFileLineHandler; -extern int* pCurrentLineNumber; -char RealLineNumber[200]; -// -// Disable MSVC warnings -// -#ifdef __VC32__ -#if 0 -..\src\RCOMP.L(95) : warning C4127: conditional expression is constant -..\src\RCOMP.L(114) : warning C4244: 'initializing' : conversion from 'const int' to 'YY_CHAR', possible loss of data -..\src\RCOMP.L(119) : warning C4244: '=' : conversion from 'const int' to 'YY_CHAR', possible loss of data -..\src\RCOMP.L(130) : warning C4102: 'find_rule' : unreferenced label -..\src\RCOMP.L(513) : warning C4244: 'initializing' : conversion from 'int' to 'YY_CHAR', possible loss of data -..\src\RCOMP.L(518) : warning C4244: '=' : conversion from 'const int' to 'YY_CHAR', possible loss of data -..\src\RCOMP.L(548) : warning C4244: '=' : conversion from 'const int' to 'YY_CHAR', possible loss of data -..\src\RCOMP.L(63) : warning C4505: 'yyunput' : unreferenced local function has been removed -\epoc32\BUILD\generatedcpp\rcomp\rcompl.cpp(243) : warning C4505: 'yy_flex_realloc' : unreferenced local function has been removed -#endif - -#pragma warning( disable : 4100 ) -#pragma warning( disable : 4102 ) -#pragma warning( disable : 4127 ) -#pragma warning( disable : 4244 ) -#pragma warning( disable : 4245 ) -#pragma warning( disable : 4505 ) -#endif //__VC32__ - -#include "errorhan.h" - -#define REGISTER_LINE ErrorHandler::Register(pFileLineHandler->GetCurrentFile(), pFileLineHandler->GetErrorLine(* pCurrentLineNumber)) - - -%} - -Digit [0-9] -Lower [a-z] -Upper [A-Z] -Letter {Lower}|{Upper} -Alphanumeric {Letter}|{Digit} -LetterOrUnderscore {Letter}|_ -AlphanumUscore {Alphanumeric}|_ -HexChar [A-Fa-f0-9] -ExpChar [eE] -FileNameChar [^"] - -%s string_rules - /* Rule set for string literals. */ - /* n.b. Exclusive rule sets i.e. %x are available in MKS only */ - /* so they are not used here; hence all the 's. */ - -%s file_line_rules - /* Rule set for file_line_directive.*/ - -%s cpp_comment - /* C++ comment to end of line */ - -%s c_comment - /* C comment */ - -%s comment_tag - /* Doxygen-style comment tag */ - -%% - - - /* Translations section */ - /* ==================== */ - - /*******************************************/ - /* Main keywords */ - /*******************************************/ -STRUCT return L_STRUCT; -RESOURCE return L_RESOURCE; -NAME return L_NAME; -CHARACTER_SET return L_CHARACTER_SET; -OFFSET return L_OFFSET; -SYSTEM return L_SYSTEM; -GLOBAL return L_GLOBAL; -LOCAL return L_LOCAL; -ENUM return L_ENUM; -enum return L_ENUM; -UID2 return L_UID_TWO; -UID3 return L_UID_THREE; -rls_string return L_RLS_STRING; -rls_string8 return L_RLS_STRING8; -rls_double return L_RLS_DOUBLE; -rls_byte return L_RLS_BYTE; -rls_word return L_RLS_WORD; -rls_long return L_RLS_LONG; -multi return L_MULTI; - - /*******************************************/ - /* Types */ - /*******************************************/ -BUF return L_BUF; -BUF8 return L_BUF8; -BUF16 return L_BUF16; -WORD return L_WORD; -BYTE return L_BYTE; -LONG return L_LONG; -DOUBLE return L_DOUBLE; -TEXT return L_TEXT; -LTEXT return L_LTEXT; -TEXT8 return L_TEXT8; -LTEXT8 return L_LTEXT8; -TEXT16 return L_TEXT16; -LTEXT16 return L_LTEXT16; -LINK return L_LINK; -LLINK return L_LLINK; -SRLINK return L_SRLINK; - - - /*******************************************/ - /* Others */ - /*******************************************/ -LEN return L_LEN; - - - /*******************************************/ - /* String & character literals */ - /*******************************************/ -\" { BEGIN(string_rules); pCh = buf; isCharLiteral=0; } -' { BEGIN(string_rules); pCh = buf; isCharLiteral=1; } - - /* Escaped single- and double-quotes.*/ -\\\" { CHECK_APPEND('"'); } -\\' { CHECK_APPEND('\''); }; - - /* Convert escaped character into corresponding actual character e.g. \t to tab. */ -\\[rbfntv] { CHECK_APPEND( * ( strchr("\rr\bb\ff\nn\tt\vv\aa", yytext[1])-1));} - - /* Escaped backslash */ -\\\\ { CHECK_APPEND('\\'); } - -\\\n /* Escaped newline ignored*/ ; - - /* End of line before terminating double-quotes.*/ -(\r)?\n { yyerror( isCharLiteral?"Unterminated character literal":"Unterminated string"); BEGIN 0; } - - /* End of string reached.*/ -\" { - if (!isCharLiteral) - { - *pCh = '\0'; BEGIN(0); strcpy( yylval.Value, buf); - return L_STRING_LITERAL; - } - CHECK_APPEND(*yytext); - } - -' { - if (isCharLiteral) - { - *pCh = '\0'; BEGIN(0); strcpy( yylval.Value, buf); return L_CHAR_LITERAL; - } - CHECK_APPEND(*yytext); - } - - /* Anything other than \n is stored.*/ -. { CHECK_APPEND(*yytext); } - - - /*******************************************/ - /* Labels */ - /*******************************************/ -{LetterOrUnderscore}{AlphanumUscore}* { - BEGIN(0); - strcpy( yylval.Value, yytext); - return L_LABEL; - } - - /*******************************************/ - /* Numbers */ - /*******************************************/ -{Digit}+ { strcpy( yylval.Value, yytext); return L_NUM_NATURAL; } -0x{HexChar}+ { strcpy( yylval.Value, yytext); return L_NUM_NATURAL; } -{Digit}+\.{Digit}+{ExpChar}{Digit}+ { strcpy( yylval.Value, yytext); return L_NUM_FLOAT;} --{Digit}+\.{Digit}+{ExpChar}{Digit}+ { strcpy( yylval.Value, yytext); return L_NUM_FLOAT;} -{Digit}+\.{Digit}+ { strcpy( yylval.Value, yytext); return L_NUM_FLOAT;} --{Digit}+\.{Digit}+ { strcpy( yylval.Value, yytext); return L_NUM_FLOAT;} -{Digit}+{ExpChar}{Digit}+ { strcpy( yylval.Value, yytext); return L_NUM_FLOAT;} --{Digit}+{ExpChar}{Digit}+ { strcpy( yylval.Value, yytext); return L_NUM_FLOAT;} - - /*******************************************/ - /* file_line_directive */ - /*******************************************/ -[#][ ]{Digit}+[ ]\" { BEGIN(file_line_rules); strcpy( RealLineNumber, yytext+2); } - -\"(\r)?$ { BEGIN(0); // # "" means start of base file. - pFileLineHandler->SetBase( InputBaseName, * pCurrentLineNumber); - } - -{FileNameChar}*\"(\r)?$ { BEGIN(0); // # means @ line of named base file. - pFileLineHandler->PostInclude( yytext, RealLineNumber, * pCurrentLineNumber); - } - -{FileNameChar}*\"[ ]1([ ]3){0,1}(\r)?$ { - BEGIN(0); // # 1 means start of an included file. - pFileLineHandler->SetInclude( yytext, * pCurrentLineNumber); - } - -{FileNameChar}*\"[ ]2([ ]3){0,1}(\r)?$ { - BEGIN(0); // # 2 means end of an included file and now at in . - pFileLineHandler->PostInclude( yytext, RealLineNumber, * pCurrentLineNumber); - } - - - - /*******************************************/ - /* White space */ - /*******************************************/ -[ \t] ; // skipped -[\n\r] ; // skipped -[\n\r] ; // skipped -"//" { BEGIN(cpp_comment); } -[\n\r] { BEGIN(0); } -. ; // skipped -"/*"/[^&\n] { BEGIN(c_comment); } -"/*"[\n\r] { BEGIN(c_comment); } -"*/" { BEGIN(0); } -[\n\r] ; // skipped -. ; // skipped - - /*******************************************/ - /* Comment tags */ - /*******************************************/ - -[ \t]*"/*&" { - BEGIN(comment_tag); - pGL->SetStart(*(pFileLineHandler->GetCurrentFile()), pFileLineHandler->GetErrorLine(* pCurrentLineNumber)); - return L_TAG_START; - } // any comment beginning with a slash followed by a star followed by an ampersand -"*/" { - BEGIN(0); - return L_TAG_END; - } -"@"[^* \t\r\n]+ { strcpy( yylval.Value, yytext); return L_TAG_COMMAND; } -[^*@ \t\n\r][^ *\t\r\n]* { strcpy( yylval.Value, yytext); return L_TAG_WORD; } -[\n\r] { strcpy( yylval.Value, "\n"); return L_TAG_NEW_LINE; } -[* \t] ; - - /*******************************************/ - /* Special single characters */ - /*******************************************/ -[.{};=\[\],()+\-*/|<>] return * yytext; - - - /*******************************************/ - /* Everything else cannot be recognised */ - /*******************************************/ -. { yyerror("*** Unknown character '%c' (value 0x%x) ", *yytext, *yytext);} +%option yylineno +%{ +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// RCOMPL.INL +// Generated from RCOMP.L + + +#include +#include +#include "main.h" +#include "STRUCTST.H" +#include "Parser.h" +#include "localise.h" + +#define YY_SKIP_YYWRAP 1 +#define YY_NEVER_INTERACTIVE 1 +int yywrap(); +void yyerror(const char* string, ...); + +// Redefine YY_INPUT so we can parse binary data. +#undef YY_INPUT +#define YY_INPUT(buf, result, max_size) (result = new_yy_input(buf, max_size)) + +int new_yy_input(char *buf, int max_size) +{ + int result; + if(yyin != NULL) { + result = fread(buf, 1, max_size, yyin); + } + else if((pG->StdInBuffer != NULL) && (pG->StdInBufLength > 0)) { + int left = pG->StdInBufLength - pG->StdInfBufPos ; + if(left == 0) + return YY_NULL ; + result = (max_size < left) ? max_size : left ; + memcpy(buf,&(pG->StdInBuffer[pG->StdInfBufPos]),result); + pG->StdInfBufPos += result ; + } + + if (result == 0) + return YY_NULL; + + const unsigned char BOM[] = {0xef , 0xbb, 0xbf, 0x0 }; + // check for utf8 (BOM) header in buf + for (int i = 0; i < result-3; i++) { + if (0 == memcmp(&buf[i],BOM,3)) { + memset(&buf[i],0x20,3); + } + } + return result; +} + +#include "rcomp.hpp" +#include "FILELINE.H" + +#define VALUE_LEN (1024*8) // must match sizeof(YYSTYPE.Value) +char buf[VALUE_LEN]; +char * pCh; +#define CHECK_APPEND(x) \ + if (pCh-buf==VALUE_LEN-1) { yyerror("string too long - %c ignored", (x)); } else {*pCh++ = (x); } + +int isCharLiteral; + +extern String InputBaseName; +extern FileLineManager* pFileLineHandler; +extern int* pCurrentLineNumber; +char RealLineNumber[200]; + +#include "ERRORHAN.H" + +#define REGISTER_LINE ErrorHandler::Register(pFileLineHandler->GetCurrentFile(), pFileLineHandler->GetErrorLine(* pCurrentLineNumber)) + + +%} + +Digit [0-9] +Lower [a-z] +Upper [A-Z] +Letter {Lower}|{Upper} +Alphanumeric {Letter}|{Digit} +LetterOrUnderscore {Letter}|_ +AlphanumUscore {Alphanumeric}|_ +HexChar [A-Fa-f0-9] +ExpChar [eE] +FileNameChar [^"] + +%s string_rules + /* Rule set for string literals. */ + /* n.b. Exclusive rule sets i.e. %x are available in MKS only */ + /* so they are not used here; hence all the 's. */ + +%s file_line_rules + /* Rule set for file_line_directive.*/ + +%s cpp_comment + /* C++ comment to end of line */ + +%s c_comment + /* C comment */ + +%s comment_tag + /* Doxygen-style comment tag */ + +%% + + + /* Translations section */ + /* ==================== */ + + /*******************************************/ + /* Main keywords */ + /*******************************************/ +STRUCT return L_STRUCT; +RESOURCE return L_RESOURCE; +NAME return L_NAME; +CHARACTER_SET return L_CHARACTER_SET; +OFFSET return L_OFFSET; +SYSTEM return L_SYSTEM; +GLOBAL return L_GLOBAL; +LOCAL return L_LOCAL; +ENUM return L_ENUM; +enum return L_ENUM; +UID2 return L_UID_TWO; +UID3 return L_UID_THREE; +rls_string return L_RLS_STRING; +rls_string8 return L_RLS_STRING8; +rls_double return L_RLS_DOUBLE; +rls_byte return L_RLS_BYTE; +rls_word return L_RLS_WORD; +rls_long return L_RLS_LONG; +multi return L_MULTI; + + /*******************************************/ + /* Types */ + /*******************************************/ +BUF return L_BUF; +BUF8 return L_BUF8; +BUF16 return L_BUF16; +WORD return L_WORD; +BYTE return L_BYTE; +LONG return L_LONG; +DOUBLE return L_DOUBLE; +TEXT return L_TEXT; +LTEXT return L_LTEXT; +TEXT8 return L_TEXT8; +LTEXT8 return L_LTEXT8; +TEXT16 return L_TEXT16; +LTEXT16 return L_LTEXT16; +LINK return L_LINK; +LLINK return L_LLINK; +SRLINK return L_SRLINK; + + + /*******************************************/ + /* Others */ + /*******************************************/ +LEN return L_LEN; + + + /*******************************************/ + /* String & character literals */ + /*******************************************/ +\" { BEGIN(string_rules); pCh = buf; isCharLiteral=0; } +' { BEGIN(string_rules); pCh = buf; isCharLiteral=1; } + + /* Escaped single- and double-quotes.*/ +\\\" { CHECK_APPEND('"'); } +\\' { CHECK_APPEND('\''); }; + + /* Convert escaped character into corresponding actual character e.g. \t to tab. */ +\\[rbfntv] { CHECK_APPEND( * ( strchr("\rr\bb\ff\nn\tt\vv\aa", yytext[1])-1));} + + /* Escaped backslash */ +\\\\ { CHECK_APPEND('\\'); } + +\\\n /* Escaped newline ignored*/ ; + + /* End of line before terminating double-quotes.*/ +(\r)?\n { yyerror( isCharLiteral?"Unterminated character literal":"Unterminated string"); BEGIN 0; } + + /* End of string reached.*/ +\" { + if (!isCharLiteral) + { + *pCh = '\0'; BEGIN(0); strcpy( yylval.Value, buf); + return L_STRING_LITERAL; + } + CHECK_APPEND(*yytext); + } + +' { + if (isCharLiteral) + { + *pCh = '\0'; BEGIN(0); strcpy( yylval.Value, buf); return L_CHAR_LITERAL; + } + CHECK_APPEND(*yytext); + } + + /* Anything other than \n is stored.*/ +. { CHECK_APPEND(*yytext); } + + + /*******************************************/ + /* Labels */ + /*******************************************/ +{LetterOrUnderscore}{AlphanumUscore}* { + BEGIN(0); + strcpy( yylval.Value, yytext); + return L_LABEL; + } + + /*******************************************/ + /* Numbers */ + /*******************************************/ +{Digit}+ { strcpy( yylval.Value, yytext); return L_NUM_NATURAL; } +0x{HexChar}+ { strcpy( yylval.Value, yytext); return L_NUM_NATURAL; } +{Digit}+\.{Digit}+{ExpChar}{Digit}+ { strcpy( yylval.Value, yytext); return L_NUM_FLOAT;} +-{Digit}+\.{Digit}+{ExpChar}{Digit}+ { strcpy( yylval.Value, yytext); return L_NUM_FLOAT;} +{Digit}+\.{Digit}+ { strcpy( yylval.Value, yytext); return L_NUM_FLOAT;} +-{Digit}+\.{Digit}+ { strcpy( yylval.Value, yytext); return L_NUM_FLOAT;} +{Digit}+{ExpChar}{Digit}+ { strcpy( yylval.Value, yytext); return L_NUM_FLOAT;} +-{Digit}+{ExpChar}{Digit}+ { strcpy( yylval.Value, yytext); return L_NUM_FLOAT;} + + /*******************************************/ + /* file_line_directive */ + /*******************************************/ +[#][ ]{Digit}+[ ]\" { BEGIN(file_line_rules); strcpy( RealLineNumber, yytext+2); } + +\"(\r)?$ { BEGIN(0); // # "" means start of base file. + pFileLineHandler->SetBase( InputBaseName, * pCurrentLineNumber); + } + +{FileNameChar}*\"(\r)?$ { BEGIN(0); // # means @ line of named base file. + pFileLineHandler->PostInclude( yytext, RealLineNumber, * pCurrentLineNumber); + } + +{FileNameChar}*\"[ ]1([ ]3){0,1}(\r)?$ { + BEGIN(0); // # 1 means start of an included file. + pFileLineHandler->SetInclude( yytext, * pCurrentLineNumber); + } + +{FileNameChar}*\"[ ]2([ ]3){0,1}(\r)?$ { + BEGIN(0); // # 2 means end of an included file and now at in . + pFileLineHandler->PostInclude( yytext, RealLineNumber, * pCurrentLineNumber); + } + + + + /*******************************************/ + /* White space */ + /*******************************************/ +[ \t] ; // skipped +[\n\r] ; // skipped +[\n\r] ; // skipped +"//" { BEGIN(cpp_comment); } +[\n\r] { BEGIN(0); } +. ; // skipped +"/*"/[^&\n] { BEGIN(c_comment); } +"/*"[\n\r] { BEGIN(c_comment); } +"*/" { BEGIN(0); } +[\n\r] ; // skipped +. ; // skipped + + /*******************************************/ + /* Comment tags */ + /*******************************************/ + +[ \t]*"/*&" { + BEGIN(comment_tag); + pGL->SetStart(*(pFileLineHandler->GetCurrentFile()), pFileLineHandler->GetErrorLine(* pCurrentLineNumber)); + return L_TAG_START; + } // any comment beginning with a slash followed by a star followed by an ampersand +"*/" { + BEGIN(0); + return L_TAG_END; + } +"@"[^* \t\r\n]+ { strcpy( yylval.Value, yytext); return L_TAG_COMMAND; } +[^*@ \t\n\r][^ *\t\r\n]* { strcpy( yylval.Value, yytext); return L_TAG_WORD; } +[\n\r] { strcpy( yylval.Value, "\n"); return L_TAG_NEW_LINE; } +[* \t] ; + + /*******************************************/ + /* Special single characters */ + /*******************************************/ +[.{};=\[\],()+\-*/|<>] return * yytext; + + + /*******************************************/ + /* Everything else cannot be recognised */ + /*******************************************/ +. { yyerror("*** Unknown character '%c' (value 0x%x) ", *yytext, *yytext);}