File: arg_lexer.l

package info (click to toggle)
android-file-transfer 4.5-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,496 kB
  • sloc: cpp: 12,909; python: 140; lex: 47; xml: 26; sh: 13; makefile: 6
file content (47 lines) | stat: -rw-r--r-- 1,138 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
%option noyywrap nounput
%option reentrant
%option 8bit
%option nounistd
%option batch
%option never-interactive
%option prefix="args_"

%top {
#	include <cli/Tokenizer.h>
#	define register
}

%{
#	include <stdio.h>
#	include <stdlib.h>
#	include <iostream>
#	include <sstream>

#	define LVAL (yylval_param)
#	define PARSER (reinterpret_cast<cli::Tokenizer *>(yyget_extra(yyscanner)))
#	define YY_INPUT(buf,result,max_size) result = PARSER->Input(buf, max_size);

static void yy_fatal_error(const char*, yyscan_t);
void (*hide_warning)(const char*, yyscan_t) = &yy_fatal_error;

%}

%x STRING

%%

\"											{ BEGIN(STRING); }

<STRING>\\n									{ PARSER->Write('\n'); }
<STRING>\\t									{ PARSER->Write('\t'); }
<STRING>\\f									{ PARSER->Write('\f'); }
<STRING>\\r									{ PARSER->Write('\r'); }
<STRING>\\b									{ PARSER->Write('\b'); }
<STRING>\\.									{ PARSER->Write(yytext[1]); }
<STRING>\"									{ BEGIN(INITIAL); }
<STRING>[^\\\"]+							{ PARSER->Write(yytext, yyleng); }

"\\ "										{ PARSER->Write(' '); }
[[:space:]]+								{ PARSER->NextArgument(); }
<*>.										{ PARSER->Write(yytext[0]); }
%%