summaryrefslogtreecommitdiff
path: root/scan.l
diff options
context:
space:
mode:
authorJohn Millaway <john43@users.sourceforge.net>2003-03-27 18:02:58 +0000
committerJohn Millaway <john43@users.sourceforge.net>2003-03-27 18:02:58 +0000
commit17551916f3f63d31562c1c6c15ea8749b4a9279b (patch)
treee815f489a1aa347b4f19acfaafbde5f3bb75a61b /scan.l
parent6fe6068dee3020caf4bd93c2c7d71c675df3201d (diff)
Added %top block syntax.
Added test for %top block. Documented %top block.
Diffstat (limited to 'scan.l')
-rw-r--r--scan.l43
1 files changed, 41 insertions, 2 deletions
diff --git a/scan.l b/scan.l
index bb694a3..ab48a40 100644
--- a/scan.l
+++ b/scan.l
@@ -95,7 +95,7 @@ extern bool tablesverify, tablesext;
%x SECT2 SECT2PROLOG SECT3 CODEBLOCK PICKUPDEF SC CARETISBOL NUM QUOTE
%x FIRSTCCL CCL ACTION RECOVER COMMENT ACTION_STRING PERCENT_BRACE_ACTION
-%x OPTION LINEDIR
+%x OPTION LINEDIR CODEBLOCK_MATCH_BRACE
WS [[:blank:]]+
OPTWS [[:blank:]]*
@@ -122,7 +122,7 @@ LEXOPT [aceknopr]
static int option_sense;
int doing_codeblock = false;
- int i;
+ int i, brace_depth=0, brace_start_line=0;
Char nmdef[MAXLINE];
@@ -138,6 +138,15 @@ LEXOPT [aceknopr]
indented_code = false;
BEGIN(CODEBLOCK);
}
+ ^"%top"[[:blank:]]*"{"[[:blank:]]*{NL} {
+ brace_start_line = linenum;
+ ++linenum;
+ buf_linedir( &top_buf, infilename?infilename:"<stdin>", linenum);
+ brace_depth = 1;
+ yy_push_state(CODEBLOCK_MATCH_BRACE);
+ }
+
+ ^"%top".* synerr( _("malformed '%top' directive") );
{WS} /* discard */
@@ -214,6 +223,36 @@ LEXOPT [aceknopr]
}
}
+<CODEBLOCK_MATCH_BRACE>{
+ "}" {
+ if( --brace_depth == 0){
+ /* TODO: Matched. */
+ yy_pop_state();
+ }else
+ buf_strnappend(&top_buf, yytext, yyleng);
+ }
+
+ "{" {
+ brace_depth++;
+ buf_strnappend(&top_buf, yytext, yyleng);
+ }
+
+ {NL} {
+ ++linenum;
+ buf_strnappend(&top_buf, yytext, yyleng);
+ }
+
+ [^{}\r\n]+ {
+ buf_strnappend(&top_buf, yytext, yyleng);
+ }
+
+ <<EOF>> {
+ linenum = brace_start_line;
+ synerr(_("Unmatched '{'"));
+ yyterminate();
+ }
+}
+
<PICKUPDEF>{
{WS} /* separates name and definition */