1 /* scan.l - scanner for flex input -*-C-*- */
4 /* Copyright (c) 1990 The Regents of the University of California. */
5 /* All rights reserved. */
7 /* This code is derived from software contributed to Berkeley by */
10 /* The United States Government has rights in this work pursuant */
11 /* to contract no. DE-AC03-76SF00098 between the United States */
12 /* Department of Energy and the University of California. */
14 /* This file is part of flex. */
16 /* Redistribution and use in source and binary forms, with or without */
17 /* modification, are permitted provided that the following conditions */
20 /* 1. Redistributions of source code must retain the above copyright */
21 /* notice, this list of conditions and the following disclaimer. */
22 /* 2. Redistributions in binary form must reproduce the above copyright */
23 /* notice, this list of conditions and the following disclaimer in the */
24 /* documentation and/or other materials provided with the distribution. */
26 /* Neither the name of the University nor the names of its contributors */
27 /* may be used to endorse or promote products derived from this software */
28 /* without specific prior written permission. */
30 /* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
31 /* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
32 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
37 extern bool tablesverify, tablesext;
38 extern int trlcontxt; /* Set in parse.y for each rule. */
39 extern const char *escaped_qstart, *escaped_qend;
42 #define M4QSTART "[""["
45 #define ESCAPED_QSTART "[" M4QEND M4QSTART "[" M4QEND M4QSTART
46 #define ESCAPED_QEND M4QEND "]" M4QSTART M4QEND "]" M4QSTART
48 #define ACTION_ECHO add_action( yytext )
49 #define ACTION_IFDEF(def, should_define) \
51 if ( should_define ) \
52 action_define( def, 1 ); \
55 #define ACTION_ECHO_QSTART add_action (ESCAPED_QSTART)
56 #define ACTION_ECHO_QEND add_action (ESCAPED_QEND)
58 #define ACTION_M4_IFDEF(def, should_define) \
60 if ( should_define ) \
61 buf_m4_define( &m4defs_buf, def, NULL);\
63 buf_m4_undefine( &m4defs_buf, def);\
66 #define MARK_END_OF_PROLOG mark_prolog();
72 yylval = (unsigned char) yytext[0]; \
76 if(yyleng < MAXLINE) \
78 strncpy( nmstr, yytext, sizeof(nmstr) ); \
83 synerr(_("Input line too long\n")); \
84 FLEX_EXIT(EXIT_FAILURE); \
87 #define PUT_BACK_STRING(str, start) \
88 { size_t i = strlen( str ); \
93 #define CHECK_REJECT(str) \
94 if ( all_upper( str ) ) \
97 #define CHECK_YYMORE(str) \
98 if ( all_lower( str ) ) \
101 #define YY_USER_INIT \
102 if ( getenv("POSIXLY_CORRECT") ) \
105 #define START_CODEBLOCK(x) do { \
106 /* Emit the needed line directive... */\
107 if (indented_code == false) { \
109 line_directive_out(NULL, 1); \
111 add_action(M4QSTART); \
112 yy_push_state(CODEBLOCK); \
113 if ((indented_code = x)) ACTION_ECHO; \
116 #define END_CODEBLOCK do { \
118 add_action(M4QEND); \
119 if (!indented_code) line_directive_out(NULL, 0);\
124 %option caseless nodefault noreject stack noyy_top_state
127 %x SECT2 SECT2PROLOG SECT3 CODEBLOCK PICKUPDEF SC CARETISBOL NUM QUOTE
128 %x FIRSTCCL CCL ACTION RECOVER COMMENT ACTION_STRING PERCENT_BRACE_ACTION
129 %x OPTION LINEDIR CODEBLOCK_MATCH_BRACE
131 %x GROUP_MINUS_PARAMS
133 %x COMMENT_DISCARD CODE_COMMENT
135 %x CHARACTER_CONSTANT
139 NOT_WS [^[:blank:]\r\n]
143 NAME ([[:alpha:]_][[:alnum:]_-]*)
144 NOT_NAME [^[:alpha:]_*\n]+
148 ESCSEQ (\\([^\n]|[0-7]{1,3}|x[[:xdigit:]]{1,2}))
150 FIRST_CCL_CHAR ([^\\\n]|{ESCSEQ})
151 CCL_CHAR ([^\\\n\]]|{ESCSEQ})
152 CCL_EXPR ("[:"^?[[:alpha:]]+":]")
160 static int bracelevel, didadef, indented_code;
161 static int doing_rule_action = false;
162 static int option_sense;
164 int doing_codeblock = false;
165 int brace_depth=0, brace_start_line=0;
170 ^{WS} START_CODEBLOCK(true);
171 ^"/*" add_action("/*[""["); yy_push_state( COMMENT );
172 ^#{OPTWS}line{WS} yy_push_state( LINEDIR );
173 ^"%s"{NAME}? return SCDECL;
174 ^"%x"{NAME}? return XSCDECL;
175 ^"%{".*{NL} START_CODEBLOCK(false);
176 ^"%top"[[:blank:]]*"{"[[:blank:]]*{NL} {
177 brace_start_line = linenum;
179 buf_linedir( &top_buf, infilename?infilename:"<stdin>", linenum);
181 yy_push_state(CODEBLOCK_MATCH_BRACE);
184 ^"%top".* synerr( _("malformed '%top' directive") );
192 line_directive_out(NULL, 1);
197 ^"%pointer".*{NL} yytext_is_array = false; ++linenum;
198 ^"%array".*{NL} yytext_is_array = true; ++linenum;
200 ^"%option" BEGIN(OPTION); return TOK_OPTION;
202 ^"%"{LEXOPT}{OPTWS}[[:digit:]]*{OPTWS}{NL} ++linenum; /* ignore */
203 ^"%"{LEXOPT}{WS}.*{NL} ++linenum; /* ignore */
205 /* xgettext: no-c-format */
206 ^"%"[^sxaceknopr{}].* synerr( _( "unrecognized '%' directive" ) );
211 strncpy( nmstr, yytext, sizeof(nmstr) );
215 synerr( _("Definition name too long\n"));
216 FLEX_EXIT(EXIT_FAILURE);
224 ^{OPTWS}{NL} ++linenum; /* allows blank lines in section 1 */
225 {OPTWS}{NL} ACTION_ECHO; ++linenum; /* maybe end of comment line */
229 <COMMENT,CODE_COMMENT>{ /* */
230 [^\[\]\*\n]* ACTION_ECHO;
233 {NL} ++linenum; ACTION_ECHO;
236 "*/" add_action("*/]""]"); yy_pop_state();
239 "*/" ACTION_ECHO; yy_pop_state();
243 /* This is the same as COMMENT, but is discarded rather than output. */
258 [[:digit:]]+ linenum = myctoi( yytext );
262 infilename = xstrdup(yytext + 1);
263 infilename[strlen( infilename ) - 1] = '\0';
265 . /* ignore spurious characters */
267 <ACTION,CODEBLOCK,ACTION_STRING,PERCENT_BRACE_ACTION,CHARACTER_CONSTANT,COMMENT,CODE_COMMENT>{
268 {M4QSTART} ACTION_ECHO_QSTART;
269 {M4QEND} ACTION_ECHO_QEND;
273 ^"%}".*{NL} ++linenum; END_CODEBLOCK;
274 [^\n%\[\]]* ACTION_ECHO;
279 if ( indented_code ) END_CODEBLOCK;
283 <CODEBLOCK_MATCH_BRACE>{
285 if( --brace_depth == 0){
289 buf_strnappend(&top_buf, yytext, yyleng);
294 buf_strnappend(&top_buf, yytext, yyleng);
299 buf_strnappend(&top_buf, yytext, yyleng);
302 {M4QSTART} buf_strnappend(&top_buf, escaped_qstart, (int) strlen(escaped_qstart));
303 {M4QEND} buf_strnappend(&top_buf, escaped_qend, (int) strlen(escaped_qend));
304 ([^{}\r\n\[\]]+)|[^{}\r\n] {
305 buf_strnappend(&top_buf, yytext, yyleng);
309 linenum = brace_start_line;
310 synerr(_("Unmatched '{'"));
317 {WS} /* separates name and definition */
322 strncpy( nmdef, yytext, sizeof(nmdef) );
326 format_synerr( _("Definition value for {%s} too long\n"), nmstr);
327 FLEX_EXIT(EXIT_FAILURE);
329 /* Skip trailing whitespace. */
331 size_t i = strlen( nmdef );
332 while (i > 0 && (nmdef[i-1] == ' ' || nmdef[i-1] == '\t'))
337 ndinstal( nmstr, nmdef );
343 synerr( _( "incomplete name definition" ) );
351 {NL} ++linenum; BEGIN(INITIAL);
352 {WS} option_sense = true;
356 no option_sense = ! option_sense;
358 7bit csize = option_sense ? 128 : 256;
359 8bit csize = option_sense ? 256 : 128;
361 align long_align = option_sense;
363 ACTION_M4_IFDEF( "M4""_YY_ALWAYS_INTERACTIVE", option_sense );
364 interactive = option_sense;
366 array yytext_is_array = option_sense;
367 backup backing_up_report = option_sense;
368 batch interactive = ! option_sense;
369 bison-bridge bison_bridge_lval = option_sense;
370 bison-locations { if((bison_bridge_lloc = option_sense))
371 bison_bridge_lval = true;
373 "c++" C_plus_plus = option_sense;
374 caseful|case-sensitive sf_set_case_ins(!option_sense);
375 caseless|case-insensitive sf_set_case_ins(option_sense);
376 debug ddebug = option_sense;
377 default spprdflt = ! option_sense;
378 ecs useecs = option_sense;
380 useecs = usemecs = false;
381 use_read = fullspd = true;
384 useecs = usemecs = false;
385 use_read = fulltbl = true;
387 input ACTION_IFDEF("YY_NO_INPUT", ! option_sense);
388 interactive interactive = option_sense;
389 lex-compat lex_compat = option_sense;
390 posix-compat posix_compat = option_sense;
391 line gen_line_dirs = option_sense;
393 ACTION_M4_IFDEF( "M4""_YY_MAIN", option_sense);
394 /* Override yywrap */
395 if( option_sense == true )
398 meta-ecs usemecs = option_sense;
400 ACTION_M4_IFDEF( "M4""_YY_NEVER_INTERACTIVE", option_sense );
401 interactive = !option_sense;
403 perf-report performance_report += option_sense ? 1 : -1;
404 pointer yytext_is_array = ! option_sense;
405 read use_read = option_sense;
406 reentrant reentrant = option_sense;
407 reject reject_really_used = option_sense;
408 stack ACTION_M4_IFDEF( "M4""_YY_STACK_USED", option_sense );
409 stdinit do_stdinit = option_sense;
410 stdout use_stdout = option_sense;
411 unistd ACTION_IFDEF("YY_NO_UNISTD_H", ! option_sense);
412 unput ACTION_M4_IFDEF("M4""_YY_NO_UNPUT", ! option_sense);
413 verbose printstats = option_sense;
414 warn nowarn = ! option_sense;
415 yylineno do_yylineno = option_sense; ACTION_M4_IFDEF("M4""_YY_USE_LINENO", option_sense);
416 yymore yymore_really_used = option_sense;
417 yywrap do_yywrap = option_sense;
419 yy_push_state ACTION_M4_IFDEF("M4""_YY_NO_PUSH_STATE", ! option_sense);
420 yy_pop_state ACTION_M4_IFDEF("M4""_YY_NO_POP_STATE", ! option_sense);
421 yy_top_state ACTION_M4_IFDEF("M4""_YY_NO_TOP_STATE", ! option_sense);
423 yy_scan_buffer ACTION_M4_IFDEF("M4""_YY_NO_SCAN_BUFFER", ! option_sense);
424 yy_scan_bytes ACTION_M4_IFDEF("M4""_YY_NO_SCAN_BYTES", ! option_sense);
425 yy_scan_string ACTION_M4_IFDEF("M4""_YY_NO_SCAN_STRING", ! option_sense);
427 yyalloc ACTION_M4_IFDEF("M4""_YY_NO_FLEX_ALLOC", ! option_sense);
428 yyrealloc ACTION_M4_IFDEF("M4""_YY_NO_FLEX_REALLOC", ! option_sense);
429 yyfree ACTION_M4_IFDEF("M4""_YY_NO_FLEX_FREE", ! option_sense);
431 yyget_debug ACTION_M4_IFDEF("M4""_YY_NO_GET_DEBUG", ! option_sense);
432 yyset_debug ACTION_M4_IFDEF("M4""_YY_NO_SET_DEBUG", ! option_sense);
433 yyget_extra ACTION_M4_IFDEF("M4""_YY_NO_GET_EXTRA", ! option_sense);
434 yyset_extra ACTION_M4_IFDEF("M4""_YY_NO_SET_EXTRA", ! option_sense);
435 yyget_leng ACTION_M4_IFDEF("M4""_YY_NO_GET_LENG", ! option_sense);
436 yyget_text ACTION_M4_IFDEF("M4""_YY_NO_GET_TEXT", ! option_sense);
437 yyget_lineno ACTION_M4_IFDEF("M4""_YY_NO_GET_LINENO", ! option_sense);
438 yyset_lineno ACTION_M4_IFDEF("M4""_YY_NO_SET_LINENO", ! option_sense);
439 yyget_in ACTION_M4_IFDEF("M4""_YY_NO_GET_IN", ! option_sense);
440 yyset_in ACTION_M4_IFDEF("M4""_YY_NO_SET_IN", ! option_sense);
441 yyget_out ACTION_M4_IFDEF("M4""_YY_NO_GET_OUT", ! option_sense);
442 yyset_out ACTION_M4_IFDEF("M4""_YY_NO_SET_OUT", ! option_sense);
443 yyget_lval ACTION_M4_IFDEF("M4""_YY_NO_GET_LVAL", ! option_sense);
444 yyset_lval ACTION_M4_IFDEF("M4""_YY_NO_SET_LVAL", ! option_sense);
445 yyget_lloc ACTION_M4_IFDEF("M4""_YY_NO_GET_LLOC", ! option_sense);
446 yyset_lloc ACTION_M4_IFDEF("M4""_YY_NO_SET_LLOC", ! option_sense);
448 extra-type return TOK_EXTRA_TYPE;
449 outfile return TOK_OUTFILE;
450 prefix return TOK_PREFIX;
451 yyclass return TOK_YYCLASS;
452 header(-file)? return TOK_HEADER_FILE;
453 tables-file return TOK_TABLES_FILE;
455 tablesverify = option_sense;
456 if(!tablesext && option_sense)
462 if(yyleng-1 < MAXLINE)
464 strncpy( nmstr, yytext + 1, sizeof(nmstr) );
468 synerr( _("Option line too long\n"));
469 FLEX_EXIT(EXIT_FAILURE);
471 nmstr[strlen( nmstr ) - 1] = '\0';
475 (([a-mo-z]|n[a-np-z])[[:alpha:]\-+]*)|. {
476 format_synerr( _( "unrecognized %%option: %s" ),
482 <RECOVER>.*{NL} ++linenum; BEGIN(INITIAL);
486 ^"%{".* ++bracelevel; yyless( 2 ); /* eat only %{ */
487 ^"%}".* --bracelevel; yyless( 2 ); /* eat only %} */
489 ^{WS} START_CODEBLOCK(true); /* indented code in prolog */
492 /* non-indented code */
493 if ( bracelevel <= 0 ) {
494 /* not in %{ ... %} */
495 yyless( 0 ); /* put it all back */
500 START_CODEBLOCK(true);
505 {NL} ++linenum; ACTION_ECHO;
510 yyterminate(); /* to stop the parser */
515 ^{OPTWS}{NL} ++linenum; /* allow blank lines in section 2 */
518 indented_code = false;
519 doing_codeblock = true;
521 BEGIN(PERCENT_BRACE_ACTION);
525 /* Allow "<" to appear in (?x) patterns. */
530 ^{OPTWS}"^" return '^';
531 \" BEGIN(QUOTE); return '"';
534 if ( lex_compat || posix_compat )
535 return BEGIN_REPEAT_POSIX;
537 return BEGIN_REPEAT_FLEX;
539 "$"/([[:blank:]]|{NL}) return '$';
543 BEGIN(PERCENT_BRACE_ACTION);
547 doing_rule_action = true;
554 /* We're in the middle of a (?x: ) pattern. */
555 /* Push back everything starting at the "|" */
556 int amt = (int) (strchr (yytext, '|') - yytext);
561 continued_action = true;
570 /* We're in the middle of a (?x: ) pattern. */
571 yy_push_state(COMMENT_DISCARD);
574 yyless( yyleng - 2 ); /* put back '/', '*' */
576 continued_action = false;
581 ^{WS} /* allow indented rules */ ;
585 /* We're in the middle of a (?x: ) pattern. */
588 /* This rule is separate from the one below because
589 * otherwise we get variable trailing context, so
590 * we can't build the scanner using -{f,F}.
593 continued_action = false;
598 doing_rule_action = true;
607 /* We're in the middle of a (?x: ) pattern. */
612 continued_action = false;
614 unput( '\n' ); /* so <ACTION> sees it */
618 doing_rule_action = true;
626 "<<EOF>>" return EOF_OP;
630 BEGIN(no_section3_escape ? SECT3_NOESCAPE : SECT3);
631 outn("/* Begin user sect3 */");
632 yyterminate(); /* to stop the parser */
636 "["({FIRST_CCL_CHAR}|{CCL_EXPR})({CCL_CHAR}|{CCL_EXPR})* {
641 strncpy( nmstr, yytext, sizeof(nmstr) );
645 synerr( _("Input line too long\n"));
646 FLEX_EXIT(EXIT_FAILURE);
649 /* Check to see if we've already encountered this
652 if (0 /* <--- This "0" effectively disables the reuse of a
653 * character class (purely based on its source text).
654 * The reason it was disabled is so yacc/bison can parse
655 * ccl operations, such as ccl difference and union.
657 && (cclval = ccllookup( nmstr )) != 0 )
659 if ( input() != ']' )
660 synerr( _( "bad character class" ) );
668 /* We fudge a bit. We know that this ccl will
669 * soon be numbered as lastccl + 1 by cclinit.
671 cclinstal( nmstr, lastccl + 1 );
673 /* Push back everything but the leading bracket
674 * so the ccl can be rescanned.
682 "{-}" return CCL_OP_DIFF;
683 "{+}" return CCL_OP_UNION;
686 /* Check for :space: at the end of the rule so we don't
687 * wrap the expanded regex in '(' ')' -- breaking trailing
690 "{"{NAME}"}"[[:space:]]? {
692 int end_is_ws, end_ch;
694 end_ch = yytext[yyleng-1];
695 end_is_ws = end_ch != '}' ? 1 : 0;
697 if(yyleng-1 < MAXLINE)
699 strncpy( nmstr, yytext + 1, sizeof(nmstr) );
703 synerr( _("Input line too long\n"));
704 FLEX_EXIT(EXIT_FAILURE);
706 nmstr[yyleng - 2 - end_is_ws] = '\0'; /* chop trailing brace */
708 if ( (nmdefptr = ndlookup( nmstr )) == 0 )
710 _( "undefined definition {%s}" ),
714 { /* push back name surrounded by ()'s */
715 size_t len = strlen( nmdefptr );
719 if ( lex_compat || nmdefptr[0] == '^' ||
720 (len > 0 && nmdefptr[len - 1] == '$')
721 || (end_is_ws && trlcontxt && !sf_skip_ws()))
722 { /* don't use ()'s after all */
723 PUT_BACK_STRING(nmdefptr, 0);
725 if ( nmdefptr[0] == '^' )
732 PUT_BACK_STRING(nmdefptr, 0);
740 yy_push_state(COMMENT_DISCARD);
742 /* Push back the "*" and return "/" as usual. */
749 if (lex_compat || posix_compat){
750 /* Push back the "?#" and treat it like a normal parens. */
756 yy_push_state(EXTENDED_COMMENT);
760 if (lex_compat || posix_compat)
761 /* Push back the "?" and treat it like a normal parens. */
764 BEGIN(GROUP_WITH_PARAMS);
767 "(" sf_push(); return '(';
769 if (_sf_top_ix > 0) {
773 synerr(_("unbalanced parenthesis"));
776 [/|*+?.(){}] return (unsigned char) yytext[0];
782 {OPTWS}{NL}{OPTWS} ++linenum; /* Allow blank lines & continuations */
783 [,*] return (unsigned char) yytext[0];
784 ">" BEGIN(SECT2); return '>';
785 ">"/^ BEGIN(CARETISBOL); return '>';
788 format_synerr( _( "bad <start condition>: %s" ),
793 <CARETISBOL>"^" BEGIN(SECT2); return '^';
798 \" BEGIN(SECT2); return '"';
801 synerr( _( "missing quote" ) );
810 "-" BEGIN(GROUP_MINUS_PARAMS);
811 i sf_set_case_ins(1);
815 <GROUP_MINUS_PARAMS>{
817 i sf_set_case_ins(0);
823 "^"/[^-\]\n] BEGIN(CCL); return '^';
824 "^"/("-"|"]") return '^';
825 . BEGIN(CCL); RETURNCHAR;
829 -/[^\]\n] return '-';
831 "]" BEGIN(SECT2); return ']';
833 synerr( _( "bad character class" ) );
840 "[:alnum:]" BEGIN(CCL); return CCE_ALNUM;
841 "[:alpha:]" BEGIN(CCL); return CCE_ALPHA;
842 "[:blank:]" BEGIN(CCL); return CCE_BLANK;
843 "[:cntrl:]" BEGIN(CCL); return CCE_CNTRL;
844 "[:digit:]" BEGIN(CCL); return CCE_DIGIT;
845 "[:graph:]" BEGIN(CCL); return CCE_GRAPH;
846 "[:lower:]" BEGIN(CCL); return CCE_LOWER;
847 "[:print:]" BEGIN(CCL); return CCE_PRINT;
848 "[:punct:]" BEGIN(CCL); return CCE_PUNCT;
849 "[:space:]" BEGIN(CCL); return CCE_SPACE;
850 "[:upper:]" BEGIN(CCL); return CCE_UPPER;
851 "[:xdigit:]" BEGIN(CCL); return CCE_XDIGIT;
853 "[:^alnum:]" BEGIN(CCL); return CCE_NEG_ALNUM;
854 "[:^alpha:]" BEGIN(CCL); return CCE_NEG_ALPHA;
855 "[:^blank:]" BEGIN(CCL); return CCE_NEG_BLANK;
856 "[:^cntrl:]" BEGIN(CCL); return CCE_NEG_CNTRL;
857 "[:^digit:]" BEGIN(CCL); return CCE_NEG_DIGIT;
858 "[:^graph:]" BEGIN(CCL); return CCE_NEG_GRAPH;
859 "[:^lower:]" BEGIN(CCL); return CCE_NEG_LOWER;
860 "[:^print:]" BEGIN(CCL); return CCE_NEG_PRINT;
861 "[:^punct:]" BEGIN(CCL); return CCE_NEG_PUNCT;
862 "[:^space:]" BEGIN(CCL); return CCE_NEG_SPACE;
863 "[:^upper:]" BEGIN(CCL); return CCE_NEG_UPPER;
864 "[:^xdigit:]" BEGIN(CCL); return CCE_NEG_XDIGIT;
867 _( "bad character class expression: %s" ),
869 BEGIN(CCL); return CCE_ALNUM;
875 yylval = myctoi( yytext );
882 if ( lex_compat || posix_compat )
883 return END_REPEAT_POSIX;
885 return END_REPEAT_FLEX;
889 synerr( _( "bad character inside {}'s" ) );
895 synerr( _( "missing }" ) );
903 <PERCENT_BRACE_ACTION>{
904 {OPTWS}"%}".* bracelevel = 0;
906 <ACTION>"/*" ACTION_ECHO; yy_push_state( CODE_COMMENT );
911 CHECK_REJECT(yytext);
915 CHECK_YYMORE(yytext);
923 if (bracelevel <= 0 || (doing_codeblock && indented_code)) {
924 if ( doing_rule_action )
925 add_action( "\tYY_BREAK]""]\n" );
927 doing_rule_action = doing_codeblock = false;
934 /* Reject and YYmore() are checked for above, in PERCENT_BRACE_ACTION */
936 "{" ACTION_ECHO; ++bracelevel;
937 "}" ACTION_ECHO; --bracelevel;
938 [^[:alpha:]_{}\"'/\n\[\]]+ ACTION_ECHO;
940 "'"([^\'\\\n]|\\.)"'" ACTION_ECHO; /* character constant */
941 "'" ACTION_ECHO; BEGIN(CHARACTER_CONSTANT);
942 \" ACTION_ECHO; BEGIN(ACTION_STRING);
946 if (bracelevel <= 0) {
947 if ( doing_rule_action )
948 add_action( "\tYY_BREAK]""]\n" );
950 doing_rule_action = false;
958 [^\[\]\"\\\n]+ ACTION_ECHO;
959 \" ACTION_ECHO; BEGIN(ACTION);
961 <CHARACTER_CONSTANT>{
962 [^\[\]\'\\\n]+ ACTION_ECHO;
963 \' ACTION_ECHO; BEGIN(ACTION);
965 <ACTION_STRING,CHARACTER_CONSTANT>{
967 \\(\\\n)*. ACTION_ECHO;
968 {NL} ++linenum; ACTION_ECHO; if (bracelevel <= 0) { BEGIN(SECT2); } else { BEGIN(ACTION); }
972 <COMMENT,CODE_COMMENT,COMMENT_DISCARD,ACTION,ACTION_STRING,CHARACTER_CONSTANT><<EOF>> {
973 synerr( _( "EOF encountered inside an action" ) );
977 <EXTENDED_COMMENT,GROUP_WITH_PARAMS,GROUP_MINUS_PARAMS><<EOF>> {
978 synerr( _( "EOF encountered inside pattern" ) );
982 <SECT2,QUOTE,FIRSTCCL,CCL>{ESCSEQ} {
983 yylval = myesc( (unsigned char *) yytext );
985 if ( YY_START == FIRSTCCL )
992 {M4QSTART} fputs(escaped_qstart, yyout);
993 {M4QEND} fputs(escaped_qend, yyout);
1002 {M4QSTART} fprintf(yyout, "[""[%s]""]", escaped_qstart);
1003 {M4QEND} fprintf(yyout, "[""[%s]""]", escaped_qend);
1011 <*>.|\n format_synerr( _( "bad character: %s" ), yytext );
1018 if ( --num_input_files > 0 )
1020 set_input_file( *++input_files );
1029 /* set_input_file - open the given file (if NULL, stdin) for scanning */
1031 void set_input_file( char *file )
1033 if ( file && strcmp( file, "-" ) )
1035 infilename = xstrdup(file);
1036 yyin = fopen( infilename, "r" );
1039 lerr( _( "can't open %s" ), file );
1045 infilename = xstrdup("<stdin>");