From 42995d7bf396933ee60c5f89c354ea89cf13df0d Mon Sep 17 00:00:00 2001 From: tpearson Date: Tue, 5 Jan 2010 00:01:18 +0000 Subject: Copy of aRts for Trinity modifications git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/dependencies/arts@1070145 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- mcopidl/scanner.ll | 183 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 mcopidl/scanner.ll (limited to 'mcopidl/scanner.ll') diff --git a/mcopidl/scanner.ll b/mcopidl/scanner.ll new file mode 100644 index 0000000..10896d2 --- /dev/null +++ b/mcopidl/scanner.ll @@ -0,0 +1,183 @@ + /* + + Copyright (C) 1999 Stefan Westerfeld + stefan@space.twc.de + + Copyright (C) 1999 Torben Weis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + + */ + +%{ + +/* + This is the lex file for mcopidl. It is based on the dcopidl (kidl) + lex file, which was written by Torben Weis. +*/ + +#define YY_NO_UNPUT +#define YY_NEVER_INTERACTIVE 1 + +#include +#include +#include +#include "common.h" + +using namespace std; +using namespace Arts; + +#ifndef KDE_USE_FINAL +#include "yacc.cc.h" +#endif + +extern int idl_line_no; +int comment_mode; + +static long ascii_to_longlong( long base, const char *s ) +{ + long ll = 0; + while( *s != '\0' ) { + char c = *s++; + if( c >= 'a' ) + c -= 'a' - 'A'; + c -= '0'; + if( c > 9 ) + c -= 'A' - '0' - 10; + ll = ll * base + c; + } + return ll; +} + +extern void startInclude(const char *line); +extern void endInclude(); + +%} + +%option noyywrap + +/*--------------------------------------------------------------------------*/ + +Digits [0-9]+ +Oct_Digit [0-7] +Hex_Digit [a-fA-F0-9] +Int_Literal [1-9][0-9]* +Oct_Literal 0{Oct_Digit}* +Hex_Literal (0x|0X){Hex_Digit}* +Esc_Sequence1 "\\"[ntvbrfa\\\?\'\"] +Esc_Sequence2 "\\"{Oct_Digit}{1,3} +Esc_Sequence3 "\\"(x|X){Hex_Digit}{1,2} +Esc_Sequence ({Esc_Sequence1}|{Esc_Sequence2}|{Esc_Sequence3}) +Char ([^\n\t\"\'\\]|{Esc_Sequence}) +Char_Literal "'"({Char}|\")"'" +String_Literal \"({Char}|"'")*\" +Float_Literal1 {Digits}"."{Digits}(e|E)("+"|"-")?{Digits} +Float_Literal2 {Digits}(e|E)("+"|"-")?{Digits} +Float_Literal3 {Digits}"."{Digits} +Float_Literal4 "."{Digits} +Float_Literal5 "."{Digits}(e|E)("+"|"-")?{Digits} + +/*--------------------------------------------------------------------------*/ + +Kidl_Identifier [_a-zA-Z][a-zA-Z0-9_]* + +Qualified_Identifier ("::")?[_a-zA-Z](("::")?[a-zA-Z0-9_])* + +/*--------------------------------------------------------------------------*/ + +%% + +[ \t] ; +[\n] { idl_line_no++; } + +"/\*" { comment_mode = 1; } +"\*/" { if (!comment_mode) { REJECT; } else { comment_mode = 0; } } +[^\n*]* { if (!comment_mode) { REJECT; } } +"*" { if (!comment_mode) { REJECT; } } + +"//"[^\n]* ; + +"#startinclude"[^\n]* { startInclude(yytext); } +"#endinclude"[^\n]* { endInclude(); } + + +"{" return T_LEFT_CURLY_BRACKET; +"}" return T_RIGHT_CURLY_BRACKET; +"(" return T_LEFT_PARANTHESIS; +")" return T_RIGHT_PARANTHESIS; +"<" return T_LESS; +">" return T_GREATER; +"," return T_COMMA; +";" return T_SEMICOLON; +":" return T_COLON; +"=" return T_EQUAL; + +void return T_VOID; +byte return T_BYTE; +long return T_LONG; +boolean return T_BOOLEAN; +string return T_STRING; +object return T_OBJECT; +struct return T_STRUCT; +interface return T_INTERFACE; +module return T_MODULE; +"enum" return T_ENUM; +attribute return T_ATTRIBUTE; +sequence return T_SEQUENCE; +readonly return T_READONLY; +in return T_IN; +out return T_OUT; +audio return T_AUDIO; +float return T_FLOAT; +stream return T_STREAM; +multi return T_MULTI; +async return T_ASYNC; +oneway return T_ONEWAY; +default return T_DEFAULT; + +{Kidl_Identifier} { + yylval._str = strdup(yytext); // TAKE CARE: free that thing + return T_IDENTIFIER; + } + +{Qualified_Identifier} { + yylval._str = strdup(yytext); // TAKE CARE: free that thing + return T_QUALIFIED_IDENTIFIER; + } + +{Int_Literal} { + yylval._int = ascii_to_longlong( 10, yytext ); + return T_INTEGER_LITERAL; + } +{Oct_Literal} { + yylval._int = ascii_to_longlong( 8, yytext ); + return T_INTEGER_LITERAL; + } +{Hex_Literal} { + yylval._int = ascii_to_longlong( 16, yytext + 2 ); + return T_INTEGER_LITERAL; + } + +. { + return T_UNKNOWN; + } + +%% + +void mcopidlInitFlex( const char *_code ) +{ + comment_mode = 0; + yy_switch_to_buffer( yy_scan_string( _code ) ); +} -- cgit v1.2.3