-/* flexscan.l - scanner for flex input */
+/* scan.l - scanner for flex input */
/*
* Copyright (c) 1987, the University of California
%{
#include "flexdef.h"
-#include "y.tab.h"
+#include "parse.h"
#define ACTION_ECHO fprintf( temp_action_file, "%s", yytext )
#define MARK_END_OF_PROLOG fprintf( temp_action_file, "%%%% end of prolog\n" );
%}
%x SECT2 SECT2PROLOG SECT3 CODEBLOCK PICKUPDEF SC CARETISBOL NUM QUOTE
-%x FIRSTCCL CCL ACTION RECOVER BRACEERROR C_COMMENT ACTION_COMMENT
+%x FIRSTCCL CCL ACTION RECOVER BRACEERROR C_COMMENT C_COMMENT_2 ACTION_COMMENT
%x ACTION_STRING PERCENT_BRACE_ACTION
WS [ \t]+
ESCSEQ \\([^^\n]|"^".|0[0-9]{1,3})
%%
- static int bracelevel;
+ static int bracelevel, didadef;
int i, cclval;
char nmdef[MAXLINE], myesc();
- static int didadef;
^{WS}.*\n ++linenum; ECHO; /* indented code */
^#.*\n ++linenum; ECHO; /* treat as a comment */
++linenum;
}
-<RECOVER>.*\n ++linenum; RETURNNAME;
+<RECOVER>.*\n ++linenum; BEGIN(0); RETURNNAME;
<SECT2PROLOG>.*\n/[^ \t\n] {
<SECT2PROLOG>.*\n ++linenum; ACTION_ECHO;
<SECT2>^{OPTWS}\n ++linenum; /* allow blank lines in section 2 */
-<SECT2>^{WS}.*\n {
+
+ /* this horrible mess of a rule matches indented lines which
+ * do not contain "/*". We need to make the distinction because
+ * otherwise this rule will be taken instead of the rule which
+ * matches the beginning of comments like this one
+ */
+<SECT2>^{WS}([^/\n]|"/"[^*\n])*("/"?)\n {
synerr( "indented code found outside of action" );
++linenum;
}
+
<SECT2>"<" BEGIN(SC); return ( '<' );
<SECT2>^"^" return ( '^' );
<SECT2>\" BEGIN(QUOTE); return ( '"' );
}
<SECT2>{WS}"|".*\n ++linenum; return ( '\n' );
+<SECT2>^{OPTWS}"/*" ACTION_ECHO; BEGIN(C_COMMENT_2);
+
<SECT2>{WS} { /* needs to be separate from following rule due to
* bug with trailing context
*/
<SECT2>^{OPTWS}\n ++linenum; return ( '\n' );
<SECT2>^"%%".* {
- /* guarentee that the SECT3 rule will have something
+ /* guarantee that the SECT3 rule will have something
* to match
*/
yyless(1);
ACTION_ECHO;
if ( bracelevel == 0 )
{
- fputs( "\tbreak;\n", temp_action_file );
+ fputs( "\tYY_BREAK\n", temp_action_file );
BEGIN(SECT2);
}
}
ACTION_ECHO;
if ( bracelevel == 0 )
{
- fputs( "\tbreak;\n", temp_action_file );
+ fputs( "\tYY_BREAK\n", temp_action_file );
BEGIN(SECT2);
}
}
<ACTION_COMMENT>\n ++linenum; ACTION_ECHO;
<ACTION_COMMENT>. ACTION_ECHO;
+<C_COMMENT_2>"*/" ACTION_ECHO; BEGIN(SECT2);
+<C_COMMENT_2>"*/".*\n ++linenum; ACTION_ECHO; BEGIN(SECT2);
+<C_COMMENT_2>[^*\n]+ ACTION_ECHO;
+<C_COMMENT_2>"*" ACTION_ECHO;
+<C_COMMENT_2>\n ++linenum; ACTION_ECHO;
+
<ACTION_STRING>[^"\\\n]+ ACTION_ECHO;
<ACTION_STRING>\\. ACTION_ECHO;
<ACTION_STRING>\n ++linenum; ACTION_ECHO;