Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/flex/dist/src Re-add.



details:   https://anonhg.NetBSD.org/src/rev/46ccfa5f4ba6
branches:  trunk
changeset: 342803:46ccfa5f4ba6
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Jan 09 18:28:41 2016 +0000

description:
Re-add.

diffstat:

 external/bsd/flex/dist/src/scan.l |  1029 +++++++++++++++++++++++++++++++++++++
 1 files changed, 1029 insertions(+), 0 deletions(-)

diffs (truncated from 1033 to 300 lines):

diff -r fb30911e49a8 -r 46ccfa5f4ba6 external/bsd/flex/dist/src/scan.l
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/flex/dist/src/scan.l Sat Jan 09 18:28:41 2016 +0000
@@ -0,0 +1,1029 @@
+/* scan.l - scanner for flex input -*-C-*- */
+
+%{
+/*  Copyright (c) 1990 The Regents of the University of California. */
+/*  All rights reserved. */
+
+/*  This code is derived from software contributed to Berkeley by */
+/*  Vern Paxson. */
+
+/*  The United States Government has rights in this work pursuant */
+/*  to contract no. DE-AC03-76SF00098 between the United States */
+/*  Department of Energy and the University of California. */
+
+/*  This file is part of flex. */
+
+/*  Redistribution and use in source and binary forms, with or without */
+/*  modification, are permitted provided that the following conditions */
+/*  are met: */
+
+/*  1. Redistributions of source code must retain the above copyright */
+/*     notice, this list of conditions and the following disclaimer. */
+/*  2. Redistributions in binary form must reproduce the above copyright */
+/*     notice, this list of conditions and the following disclaimer in the */
+/*     documentation and/or other materials provided with the distribution. */
+
+/*  Neither the name of the University nor the names of its contributors */
+/*  may be used to endorse or promote products derived from this software */
+/*  without specific prior written permission. */
+
+/*  THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
+/*  IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
+/*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
+/*  PURPOSE. */
+
+#include "flexdef.h"
+#include "parse.h"
+extern bool tablesverify, tablesext;
+extern int trlcontxt; /* Set in  parse.y for each rule. */
+extern const char *escaped_qstart, *escaped_qend;
+
+#define ACTION_ECHO add_action( yytext )
+#define ACTION_IFDEF(def, should_define) \
+       { \
+       if ( should_define ) \
+               action_define( def, 1 ); \
+       }
+
+#define ACTION_ECHO_QSTART add_action (escaped_qstart)
+#define ACTION_ECHO_QEND   add_action (escaped_qend)
+
+#define ACTION_M4_IFDEF(def, should_define) \
+    do{ \
+        if ( should_define ) \
+            buf_m4_define( &m4defs_buf, def, NULL);\
+        else \
+            buf_m4_undefine( &m4defs_buf, def);\
+    } while(0)
+
+#define MARK_END_OF_PROLOG mark_prolog();
+
+#define YY_DECL \
+       int flexscan()
+
+#define RETURNCHAR \
+       yylval = (unsigned char) yytext[0]; \
+       return CHAR;
+
+#define RETURNNAME \
+       if(yyleng < MAXLINE) \
+         { \
+       strcpy( nmstr, yytext ); \
+        } \
+       else \
+        { \
+          synerr(_("Input line too long\n")); \
+          FLEX_EXIT(EXIT_FAILURE);  \
+        }  \
+       return NAME;
+
+#define PUT_BACK_STRING(str, start) \
+       for ( i = strlen( str ) - 1; i >= start; --i ) \
+               unput((str)[i])
+
+#define CHECK_REJECT(str) \
+       if ( all_upper( str ) ) \
+               reject = true;
+
+#define CHECK_YYMORE(str) \
+       if ( all_lower( str ) ) \
+               yymore_used = true;
+
+#define YY_USER_INIT \
+       if ( getenv("POSIXLY_CORRECT") ) \
+               posix_compat = true;
+
+%}
+
+%option caseless nodefault noreject stack noyy_top_state
+%option nostdinit
+
+%x SECT2 SECT2PROLOG SECT3 CODEBLOCK PICKUPDEF SC CARETISBOL NUM QUOTE
+%x FIRSTCCL CCL ACTION RECOVER COMMENT ACTION_STRING PERCENT_BRACE_ACTION
+%x OPTION LINEDIR CODEBLOCK_MATCH_BRACE
+%x GROUP_WITH_PARAMS
+%x GROUP_MINUS_PARAMS
+%x EXTENDED_COMMENT
+%x COMMENT_DISCARD
+
+WS             [[:blank:]]+
+OPTWS          [[:blank:]]*
+NOT_WS         [^[:blank:]\r\n]
+
+NL             \r?\n
+
+NAME           ([[:alpha:]_][[:alnum:]_-]*)
+NOT_NAME       [^[:alpha:]_*\n]+
+
+SCNAME         {NAME}
+
+ESCSEQ         (\\([^\n]|[0-7]{1,3}|x[[:xdigit:]]{1,2}))
+
+FIRST_CCL_CHAR ([^\\\n]|{ESCSEQ})
+CCL_CHAR       ([^\\\n\]]|{ESCSEQ})
+CCL_EXPR       ("[:"^?[[:alpha:]]+":]")
+
+LEXOPT         [aceknopr]
+
+M4QSTART    "[["
+M4QEND      "]]"
+
+%%
+       static int bracelevel, didadef, indented_code;
+       static int doing_rule_action = false;
+       static int option_sense;
+
+       int doing_codeblock = false;
+       int i, brace_depth=0, brace_start_line=0;
+       Char nmdef[MAXLINE];
+
+
+<INITIAL>{
+       ^{WS}           indented_code = true; BEGIN(CODEBLOCK);
+       ^"/*"           ACTION_ECHO; yy_push_state( COMMENT );
+       ^#{OPTWS}line{WS}       yy_push_state( LINEDIR );
+       ^"%s"{NAME}?    return SCDECL;
+       ^"%x"{NAME}?    return XSCDECL;
+       ^"%{".*{NL}     {
+                       ++linenum;
+                       line_directive_out( (FILE *) 0, 1 );
+                       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 */
+
+       ^"%%".*         {
+                       sectnum = 2;
+                       bracelevel = 0;
+                       mark_defs1();
+                       line_directive_out( (FILE *) 0, 1 );
+                       BEGIN(SECT2PROLOG);
+                       return SECTEND;
+                       }
+
+       ^"%pointer".*{NL}       yytext_is_array = false; ++linenum;
+       ^"%array".*{NL}         yytext_is_array = true; ++linenum;
+
+       ^"%option"      BEGIN(OPTION); return OPTION_OP;
+
+       ^"%"{LEXOPT}{OPTWS}[[:digit:]]*{OPTWS}{NL}      ++linenum; /* ignore */
+       ^"%"{LEXOPT}{WS}.*{NL}  ++linenum;      /* ignore */
+
+       /* xgettext: no-c-format */
+       ^"%"[^sxaceknopr{}].*   synerr( _( "unrecognized '%' directive" ) );
+
+       ^{NAME}         {
+                       if(yyleng < MAXLINE)
+                        {
+                       strcpy( nmstr, yytext );
+                        }
+                       else
+                        {
+                          synerr( _("Definition name too long\n"));
+                          FLEX_EXIT(EXIT_FAILURE);
+                        }
+
+                       didadef = false;
+                       BEGIN(PICKUPDEF);
+                       }
+
+       {SCNAME}        RETURNNAME;
+       ^{OPTWS}{NL}    ++linenum; /* allows blank lines in section 1 */
+       {OPTWS}{NL}     ACTION_ECHO; ++linenum; /* maybe end of comment line */
+}
+
+
+<COMMENT>{
+       "*/"            ACTION_ECHO; yy_pop_state();
+       "*"             ACTION_ECHO;
+    {M4QSTART}  ACTION_ECHO_QSTART;
+    {M4QEND}    ACTION_ECHO_QEND;
+       [^*\n]      ACTION_ECHO;
+       {NL}        ++linenum; ACTION_ECHO;
+}
+
+<COMMENT_DISCARD>{
+        /* This is the same as COMMENT, but is discarded rather than output. */
+       "*/"            yy_pop_state();
+    "*"         ;
+       [^*\n]      ;
+       {NL}        ++linenum;
+}
+
+<EXTENDED_COMMENT>{
+    ")"         yy_pop_state();
+    [^\n\)]+      ;
+    {NL}        ++linenum;        
+}
+
+<LINEDIR>{
+       \n              yy_pop_state();
+       [[:digit:]]+    linenum = myctoi( yytext );
+
+       \"[^"\n]*\"     {
+                       flex_free( (void *) infilename );
+                       infilename = copy_string( yytext + 1 );
+                       infilename[strlen( infilename ) - 1] = '\0';
+                       }
+       .               /* ignore spurious characters */
+}
+
+<CODEBLOCK>{
+       ^"%}".*{NL}     ++linenum; BEGIN(INITIAL);
+
+    {M4QSTART}  ACTION_ECHO_QSTART;
+    {M4QEND}    ACTION_ECHO_QEND;
+       .               ACTION_ECHO;
+
+       {NL}            {
+                       ++linenum;
+                       ACTION_ECHO;
+                       if ( indented_code )
+                               BEGIN(INITIAL);
+                       }
+}
+
+<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);
+            }
+
+    {M4QSTART}  buf_strnappend(&top_buf, escaped_qstart, strlen(escaped_qstart));
+    {M4QEND}    buf_strnappend(&top_buf, escaped_qend, strlen(escaped_qend));
+
+    [^{}\r\n]  {
+                buf_strnappend(&top_buf, yytext, yyleng);
+               }
+
+    <<EOF>>     {
+                linenum = brace_start_line;
+                synerr(_("Unmatched '{'"));
+                yyterminate();
+                }
+}
+
+
+<PICKUPDEF>{
+       {WS}            /* separates name and definition */
+
+       {NOT_WS}[^\r\n]*        {
+                       if(yyleng < MAXLINE)
+                        {
+                       strcpy( (char *) nmdef, yytext );



Home | Main Index | Thread Index | Old Index