Source-Changes-HG archive

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

[src/trunk]: src/external/bsd/flex Add build glue and old manual page, since ...



details:   https://anonhg.NetBSD.org/src/rev/5f28898dc0ac
branches:  trunk
changeset: 748505:5f28898dc0ac
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Oct 26 00:49:03 2009 +0000

description:
Add build glue and old manual page, since the new one is content free.

diffstat:

 external/bsd/flex/Makefile         |     5 +
 external/bsd/flex/Makefile.inc     |    13 +
 external/bsd/flex/bin/Makefile     |    65 +
 external/bsd/flex/bin/flex.1       |  4251 ++++++++++++++++++++++++++++++++++++
 external/bsd/flex/include/config.h |   202 +
 external/bsd/flex/lib/Makefile     |    24 +
 6 files changed, 4560 insertions(+), 0 deletions(-)

diffs (truncated from 4584 to 300 lines):

diff -r b88711800e3f -r 5f28898dc0ac external/bsd/flex/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/flex/Makefile        Mon Oct 26 00:49:03 2009 +0000
@@ -0,0 +1,5 @@
+#      $NetBSD: Makefile,v 1.1 2009/10/26 00:49:03 christos Exp $
+
+SUBDIR=        lib bin
+
+.include <bsd.subdir.mk>
diff -r b88711800e3f -r 5f28898dc0ac external/bsd/flex/Makefile.inc
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/flex/Makefile.inc    Mon Oct 26 00:49:03 2009 +0000
@@ -0,0 +1,13 @@
+#      $NetBSD: Makefile.inc,v 1.1 2009/10/26 00:49:04 christos Exp $
+
+WARNS?=        1
+
+.include <bsd.own.mk>
+
+BINDIR?= /usr/bin
+
+IDIST= ${NETBSDSRCDIR}/external/bsd/flex/dist
+
+CPPFLAGS+= -DHAVE_CONFIG_H -I${.CURDIR}/../include -I${IDIST}
+
+.PATH: ${IDIST}
diff -r b88711800e3f -r 5f28898dc0ac external/bsd/flex/bin/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/flex/bin/Makefile    Mon Oct 26 00:49:03 2009 +0000
@@ -0,0 +1,65 @@
+#      from: @(#)Makefile      5.4 (Berkeley) 6/24/90
+#      $NetBSD: Makefile,v 1.1 2009/10/26 00:49:04 christos Exp $
+#
+# By default, flex will be configured to generate 8-bit scanners only if the
+# -8 flag is given.  If you want it to always generate 8-bit scanners, add
+# "-DDEFAULT_CSIZE=256" to CPPFLAGS.  Note that doing so will double the size
+# of all uncompressed scanners.
+# 
+# If on your system you have trouble building flex due to 8-bit character
+# problems, remove the -8 from FLEX_FLAGS and the "#define FLEX_8_BIT_CHARS"
+# from the beginning of flexdef.h.
+#
+# To bootstrap lex, cp initscan.c to scan.c and run make.
+
+PROG=  lex
+CPPFLAGS+=-I. -I${.CURDIR}
+SRCS=   \
+buf.c \
+ccl.c \
+dfa.c \
+ecs.c \
+filter.c \
+gen.c \
+main.c \
+misc.c \
+nfa.c \
+options.c \
+parse.y \
+regex.c \
+scan.c \
+scanflags.c \
+scanopt.c \
+skel.c \
+sym.c \
+tables.c \
+tables_shared.c \
+tblcmp.c \
+yylex.c
+
+YHEADER=1
+CLEANFILES+=scan.c skel.c
+INCS   =FlexLexer.h
+INCSDIR=/usr/include/g++
+LDADD+=-lm
+DPADD+=${LIBM}
+
+MAN = flex.1
+
+LINKS= ${BINDIR}/lex ${BINDIR}/flex \
+       ${BINDIR}/lex ${BINDIR}/flex++
+MLINKS=        flex.1 lex.1 
+
+skel.c:        mkskel.sh flex.skl
+       ${_MKTARGET_CREATE}
+       ${HOST_SH} ${.ALLSRC} >${.TARGET}
+
+.ifndef HOSTPROG
+scan.c: scan.l
+       ${_MKTARGET_LEX}
+       ${LEX} -t -p ${.ALLSRC} >${.TARGET}
+.endif
+
+scan.o yylex.o: parse.h
+
+.include <bsd.prog.mk>
diff -r b88711800e3f -r 5f28898dc0ac external/bsd/flex/bin/flex.1
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/flex/bin/flex.1      Mon Oct 26 00:49:03 2009 +0000
@@ -0,0 +1,4251 @@
+.\" $NetBSD: flex.1,v 1.1 2009/10/26 00:49:04 christos Exp $
+.\"
+.TH FLEX 1 "April 1995" "Version 2.5"
+.SH NAME
+flex, lex \- fast lexical analyzer generator
+.SH SYNOPSIS
+.B flex
+.B [\-bcdfhilnpstvwBFILTV78+? \-C[aefFmr] \-ooutput \-Pprefix \-Sskeleton]
+.B [\-\-help \-\-version]
+.I [filename ...]
+.SH OVERVIEW
+This manual describes
+.I flex,
+a tool for generating programs that perform pattern-matching on text.
+The manual includes both tutorial and reference sections:
+.nf
+
+    Description
+        a brief overview of the tool
+
+    Some Simple Examples
+
+    Format Of The Input File
+
+    Patterns
+        the extended regular expressions used by flex
+
+    How The Input Is Matched
+        the rules for determining what has been matched
+
+    Actions
+        how to specify what to do when a pattern is matched
+
+    The Generated Scanner
+        details regarding the scanner that flex produces;
+        how to control the input source
+
+    Start Conditions
+        introducing context into your scanners, and
+        managing "mini-scanners"
+
+    Multiple Input Buffers
+        how to manipulate multiple input sources; how to
+        scan from strings instead of files
+
+    End-of-file Rules
+        special rules for matching the end of the input
+
+    Miscellaneous Macros
+        a summary of macros available to the actions
+
+    Values Available To The User
+        a summary of values available to the actions
+
+    Interfacing With Yacc
+        connecting flex scanners together with yacc parsers
+
+    Options
+        flex command-line options, and the "%option"
+        directive
+
+    Performance Considerations
+        how to make your scanner go as fast as possible
+
+    Generating C++ Scanners
+        the (experimental) facility for generating C++
+        scanner classes
+
+    Incompatibilities With Lex And POSIX
+        how flex differs from AT\*[Am]T lex and the POSIX lex
+        standard
+
+    Diagnostics
+        those error messages produced by flex (or scanners
+        it generates) whose meanings might not be apparent
+
+    Files
+        files used by flex
+
+    Deficiencies / Bugs
+        known problems with flex
+
+    See Also
+        other documentation, related tools
+
+    Author
+        includes contact information
+
+.fi
+.SH DESCRIPTION
+.I flex
+is a tool for generating
+.I scanners:
+programs which recognized lexical patterns in text.
+.I flex
+reads
+the given input files, or its standard input if no file names are given,
+for a description of a scanner to generate.
+The description is in the form of pairs
+of regular expressions and C code, called
+.I rules.
+.I flex
+generates as output a C source file,
+.B lex.yy.c,
+which defines a routine
+.B yylex().
+This file is compiled and linked with the
+.B \-lfl
+library to produce an executable.
+When the executable is run,
+it analyzes its input for occurrences
+of the regular expressions.
+Whenever it finds one, it executes
+the corresponding C code.
+.SH SOME SIMPLE EXAMPLES
+.PP
+First some simple examples to get the flavor of how one uses
+.I flex.
+The following
+.I flex
+input specifies a scanner which whenever it encounters the string
+"username" will replace it with the user's login name:
+.nf
+
+    %%
+    username    printf( "%s", getlogin() );
+
+.fi
+By default, any text not matched by a
+.I flex
+scanner
+is copied to the output, so the net effect of this scanner is
+to copy its input file to its output with each occurrence
+of "username" expanded.
+In this input, there is just one rule.
+"username" is the
+.I pattern
+and the "printf" is the
+.I action.
+The "%%" marks the beginning of the rules.
+.PP
+Here's another simple example:
+.nf
+
+            int num_lines = 0, num_chars = 0;
+
+    %%
+    \\n      ++num_lines; ++num_chars;
+    .       ++num_chars;
+
+    %%
+    main()
+            {
+            yylex();
+            printf( "# of lines = %d, # of chars = %d\\n",
+                    num_lines, num_chars );
+            }
+
+.fi
+This scanner counts the number of characters and the number
+of lines in its input (it produces no output other than the
+final report on the counts).
+The first line
+declares two globals, "num_lines" and "num_chars", which are accessible
+both inside
+.B yylex()
+and in the
+.B main()
+routine declared after the second "%%".
+There are two rules, one
+which matches a newline ("\\n") and increments both the line count and
+the character count, and one which matches any character other than
+a newline (indicated by the "." regular expression).
+.PP
+A somewhat more complicated example:
+.nf
+
+    /* scanner for a toy Pascal-like language */
+
+    %{
+    /* need this for the call to atof() below */
+    #include \*[Lt]math.h\*[Gt]
+    %}
+
+    DIGIT    [0-9]
+    ID       [a-z][a-z0-9]*
+
+    %%
+
+    {DIGIT}+    {
+                printf( "An integer: %s (%d)\\n", yytext,
+                        atoi( yytext ) );
+                }
+
+    {DIGIT}+"."{DIGIT}*        {
+                printf( "A float: %s (%g)\\n", yytext,
+                        atof( yytext ) );
+                }
+
+    if|then|begin|end|procedure|function        {
+                printf( "A keyword: %s\\n", yytext );



Home | Main Index | Thread Index | Old Index