fix: noconfirm auto-selects first AUR match

This commit is contained in:
2026-05-08 11:01:02 +01:00
parent d39cdc3fd9
commit 153cca6132
8056 changed files with 1983098 additions and 779 deletions
@@ -0,0 +1,29 @@
# 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.
EXTRA_DIST = \
testxxLexer.l \
debflex.awk \
README
SUBDIRS = \
manual \
fastwc
@@ -0,0 +1,693 @@
# Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
# 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.
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = examples
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_cc_for_build.m4 \
$(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/iconv.m4 \
$(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/lib-ld.m4 \
$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
$(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
ctags-recursive dvi-recursive html-recursive info-recursive \
install-data-recursive install-dvi-recursive \
install-exec-recursive install-html-recursive \
install-info-recursive install-pdf-recursive \
install-ps-recursive install-recursive installcheck-recursive \
installdirs-recursive pdf-recursive ps-recursive \
tags-recursive uninstall-recursive
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
am__recursive_targets = \
$(RECURSIVE_TARGETS) \
$(RECURSIVE_CLEAN_TARGETS) \
$(am__extra_recursive_targets)
AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
distdir
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
am__DIST_COMMON = $(srcdir)/Makefile.in README
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
am__relativize = \
dir0=`pwd`; \
sed_first='s,^\([^/]*\)/.*$$,\1,'; \
sed_rest='s,^[^/]*/*,,'; \
sed_last='s,^.*/\([^/]*\)$$,\1,'; \
sed_butlast='s,/*[^/]*$$,,'; \
while test -n "$$dir1"; do \
first=`echo "$$dir1" | sed -e "$$sed_first"`; \
if test "$$first" != "."; then \
if test "$$first" = ".."; then \
dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
else \
first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
if test "$$first2" = "$$first"; then \
dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
else \
dir2="../$$dir2"; \
fi; \
dir0="$$dir0"/"$$first"; \
fi; \
fi; \
dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
done; \
reldir="$$dir2"
ACLOCAL = @ACLOCAL@
ALLOCA = @ALLOCA@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BUILD_EXEEXT = @BUILD_EXEEXT@
BUILD_OBJEXT = @BUILD_OBJEXT@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CC_FOR_BUILD = @CC_FOR_BUILD@
CFLAGS = @CFLAGS@
CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@
CPP_FOR_BUILD = @CPP_FOR_BUILD@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
GMSGFMT = @GMSGFMT@
GMSGFMT_015 = @GMSGFMT_015@
GREP = @GREP@
HELP2MAN = @HELP2MAN@
INDENT = @INDENT@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTLLIBS = @INTLLIBS@
INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
LD = @LD@
LDFLAGS = @LDFLAGS@
LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@
LEX = @LEX@
LEXLIB = @LEXLIB@
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
LIBICONV = @LIBICONV@
LIBINTL = @LIBINTL@
LIBOBJS = @LIBOBJS@
LIBPTHREAD = @LIBPTHREAD@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBICONV = @LTLIBICONV@
LTLIBINTL = @LTLIBINTL@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
M4 = @M4@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MSGFMT = @MSGFMT@
MSGFMT_015 = @MSGFMT_015@
MSGMERGE = @MSGMERGE@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
POSUB = @POSUB@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
SHELL = @SHELL@
STRIP = @STRIP@
TEXI2DVI = @TEXI2DVI@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
WARNINGFLAGS = @WARNINGFLAGS@
XGETTEXT = @XGETTEXT@
XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
YACC = @YACC@
YFLAGS = @YFLAGS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CC_FOR_BUILD = @ac_ct_CC_FOR_BUILD@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
EXTRA_DIST = \
testxxLexer.l \
debflex.awk \
README
SUBDIRS = \
manual \
fastwc
all: all-recursive
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign examples/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
# This directory's subdirectories are mostly independent; you can cd
# into them and run 'make' without going through this Makefile.
# To change the values of 'make' variables: instead of editing Makefiles,
# (1) if the variable is set in 'config.status', edit 'config.status'
# (which will cause the Makefiles to be regenerated when you run 'make');
# (2) otherwise, pass the desired values on the 'make' command line.
$(am__recursive_targets):
@fail=; \
if $(am__make_keepgoing); then \
failcom='fail=yes'; \
else \
failcom='exit 1'; \
fi; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-recursive
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-recursive
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-recursive
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
$(am__make_dryrun) \
|| test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
$(am__relativize); \
new_distdir=$$reldir; \
dir1=$$subdir; dir2="$(top_distdir)"; \
$(am__relativize); \
new_top_distdir=$$reldir; \
echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
($(am__cd) $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$$new_top_distdir" \
distdir="$$new_distdir" \
am__remove_distdir=: \
am__skip_length_check=: \
am__skip_mode_fix=: \
distdir) \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-recursive
all-am: Makefile
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-recursive
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
html-am:
info: info-recursive
info-am:
install-data-am:
install-dvi: install-dvi-recursive
install-dvi-am:
install-exec-am:
install-html: install-html-recursive
install-html-am:
install-info: install-info-recursive
install-info-am:
install-man:
install-pdf: install-pdf-recursive
install-pdf-am:
install-ps: install-ps-recursive
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am:
.MAKE: $(am__recursive_targets) install-am install-strip
.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \
check-am clean clean-generic clean-libtool cscopelist-am ctags \
ctags-am distclean distclean-generic distclean-libtool \
distclean-tags distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
installdirs-am maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
ps ps-am tags tags-am uninstall uninstall-am
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
@@ -0,0 +1,15 @@
This directory contains some examples of what you can do with
flex. These files are not tested regularly so you might have to tinker
a bit before they work for you. Updates, new files and patches are welcome.
- debflex.awk, an awk script for anotating flex debug output.
It presently only works with gawk and mawk, not with "old"
or "new" awk.
- testxxLexer.l, a sample C++ program that uses flex's scanner
class option ("-+").
- fastwc/, a subdirectory containing examples of how to use flex
to write progressively higher-performance versions of the Unix
"wc" utility. This certainly should work with 2.5, but hasn't
been tested.
@@ -0,0 +1,119 @@
# Clarify the flex debug trace by substituting first line of each rule.
# Francois Pinard <pinard@iro.umontreal.ca>, July 1990.
#
# Rewritten to process correctly \n's in scanner input.
# BEGIN section modified to correct a collection of rules.
# Michal Jaegermann <michal@phys.ualberta.ca>, December 1993
#
# Sample usage:
# flex -d PROGRAM.l
# gcc -o PROGRAM PROGRAM.c -lfl
# PROGRAM 2>&1 | gawk -f debflex.awk PROGRAM.l
#
# (VP's note: this script presently does not work with either "old" or
# "new" awk; fixes so it does will be welcome)
BEGIN {
# Insure proper usage.
if (ARGC != 2) {
print "usage: gawk -f debflex.awk FLEX_SOURCE <DEBUG_OUTPUT";
exit (1);
}
# Remove and save the name of flex source.
source = ARGV[1];
ARGC--;
# Swallow the flex source file.
line = 0;
section = 1;
while (getline <source) {
# Count the lines.
line++;
# Count the sections. When encountering section 3,
# break out of the awk BEGIN block.
if (match ($0, /^%%/)) {
section++;
if (section == 3) {
break;
}
}
else {
# Only the lines in section 2 which do not begin in a
# tab or space might be referred to by the flex debug
# trace. Save only those lines.
if (section == 2 && match ($0, /^[^ \t]/)) {
rules[line] = $0;
}
}
}
dashes = "-----------------------------------------------------------";
collect = "";
line = 0;
}
# collect complete rule output from a scanner
$0 !~ /^--/ {
collect = collect "\n" $0;
next;
}
# otherwise we have a new rule - process what we got so far
{
process();
}
# and the same thing if we hit EOF
END {
process();
}
function process() {
# splitting this way we loose some double dashes and
# left parentheses from echoed input - a small price to pay
n = split(collect, field, "\n--|[(]");
# this loop kicks in only when we already collected something
for (i = 1; i <= n; i++) {
if (0 != line) {
# we do not care for traces of newlines.
if (0 == match(field[i], /\"\n+\"[)]/)) {
if (rules[line]) {
text = field[i];
while ( ++i <= n) {
text = text field[i];
}
printf("%s:%d: %-8s -- %s\n",
source, line, text, rules[line]);
}
else {
print;
printf "%s:%d: *** No such rule.\n", source, line;
}
}
line = 0;
break;
}
if ("" != field[i]) {
if ("end of buffer or a NUL)" == field[i]) {
print dashes; # Simplify trace of buffer reloads
continue;
}
if (match(field[i], /accepting rule at line /)) {
# force interpretation of line as a number
line = 0 + substr(field[i], RLENGTH);
continue;
}
# echo everything else
printf("--%s\n", field[i]);
}
}
collect = "\n" $0; # ... and start next trace
}
@@ -0,0 +1,29 @@
# 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.
EXTRA_DIST = \
wc5.l \
wc4.l \
wc3.l \
wc2.l \
wc1.l \
mywc.c \
README
@@ -0,0 +1,513 @@
# Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
# 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.
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = examples/fastwc
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_cc_for_build.m4 \
$(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/iconv.m4 \
$(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/lib-ld.m4 \
$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
$(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
SOURCES =
DIST_SOURCES =
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
am__DIST_COMMON = $(srcdir)/Makefile.in README
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
ALLOCA = @ALLOCA@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BUILD_EXEEXT = @BUILD_EXEEXT@
BUILD_OBJEXT = @BUILD_OBJEXT@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CC_FOR_BUILD = @CC_FOR_BUILD@
CFLAGS = @CFLAGS@
CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@
CPP_FOR_BUILD = @CPP_FOR_BUILD@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
GMSGFMT = @GMSGFMT@
GMSGFMT_015 = @GMSGFMT_015@
GREP = @GREP@
HELP2MAN = @HELP2MAN@
INDENT = @INDENT@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTLLIBS = @INTLLIBS@
INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
LD = @LD@
LDFLAGS = @LDFLAGS@
LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@
LEX = @LEX@
LEXLIB = @LEXLIB@
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
LIBICONV = @LIBICONV@
LIBINTL = @LIBINTL@
LIBOBJS = @LIBOBJS@
LIBPTHREAD = @LIBPTHREAD@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBICONV = @LTLIBICONV@
LTLIBINTL = @LTLIBINTL@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
M4 = @M4@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MSGFMT = @MSGFMT@
MSGFMT_015 = @MSGFMT_015@
MSGMERGE = @MSGMERGE@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
POSUB = @POSUB@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
SHELL = @SHELL@
STRIP = @STRIP@
TEXI2DVI = @TEXI2DVI@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
WARNINGFLAGS = @WARNINGFLAGS@
XGETTEXT = @XGETTEXT@
XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
YACC = @YACC@
YFLAGS = @YFLAGS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CC_FOR_BUILD = @ac_ct_CC_FOR_BUILD@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
EXTRA_DIST = \
wc5.l \
wc4.l \
wc3.l \
wc2.l \
wc1.l \
mywc.c \
README
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/fastwc/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign examples/fastwc/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
tags TAGS:
ctags CTAGS:
cscope cscopelist:
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am:
.MAKE: install-am install-strip
.PHONY: all all-am check check-am clean clean-generic clean-libtool \
cscopelist-am ctags-am distclean distclean-generic \
distclean-libtool distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags-am uninstall uninstall-am
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
@@ -0,0 +1,56 @@
This directory contains some examples illustrating techniques for extracting
high-performance from flex scanners. Each program implements a simplified
version of the Unix "wc" tool: read text from stdin and print the number of
characters, words, and lines present in the text. All programs were compiled
using gcc (version unavailable, sorry) with the -O flag, and run on a
SPARCstation 1+. The input used was a PostScript file, mainly containing
figures, with the following "wc" counts:
lines words characters
214217 635954 2592172
The basic principles illustrated by these programs are:
- match as much text with each rule as possible
- adding rules does not slow you down!
- avoid backing up
and the big caveat that comes with them is:
- you buy performance with decreased maintainability; make
sure you really need it before applying the above techniques.
See the "Performance Considerations" section of flexdoc for more
details regarding these principles.
The different versions of "wc":
mywc.c
a simple but fairly efficient C version
wc1.l a naive flex "wc" implementation
wc2.l somewhat faster; adds rules to match multiple tokens at once
wc3.l faster still; adds more rules to match longer runs of tokens
wc4.l fastest; still more rules added; hard to do much better
using flex (or, I suspect, hand-coding)
wc5.l identical to wc3.l except one rule has been slightly
shortened, introducing backing-up
Timing results (all times in user CPU seconds):
program time notes
------- ---- -----
wc1 16.4 default flex table compression (= -Cem)
wc1 6.7 -Cf compression option
/bin/wc 5.8 Sun's standard "wc" tool
mywc 4.6 simple but better C implementation!
wc2 4.6 as good as C implementation; built using -Cf
wc3 3.8 -Cf
wc4 3.3 -Cf
wc5 5.7 -Cf; ouch, backing up is expensive
@@ -0,0 +1,26 @@
/* A simple but fairly efficient C version of the Unix "wc" tool */
#include <stdio.h>
#include <ctype.h>
main()
{
int c, cc = 0, wc = 0, lc = 0;
FILE *f = stdin;
while ((c = getc(f)) != EOF) {
++cc;
if (isgraph(c)) {
++wc;
do {
c = getc(f);
if (c == EOF)
goto done;
++cc;
} while (isgraph(c));
}
if (c == '\n')
++lc;
}
done: printf( "%8d%8d%8d\n", lc, wc, cc );
}
@@ -0,0 +1,19 @@
/* First cut at a flex-based "wc" tool. */
ws [ \t]
nonws [^ \t\n]
%option main noyywrap
%%
int cc = 0, wc = 0, lc = 0;
{nonws}+ cc += yyleng; ++wc;
{ws}+ cc += yyleng;
\n ++lc; ++cc;
<<EOF>> {
printf( "%8d %8d %8d\n", lc, wc, cc );
yyterminate();
}
@@ -0,0 +1,21 @@
/* Somewhat faster "wc" tool: match more text with each rule */
ws [ \t]
nonws [^ \t\n]
word {ws}*{nonws}+
%option main noyywrap
%%
int cc = 0, wc = 0, lc = 0;
{word}{ws}* cc += yyleng; ++wc;
{word}{ws}*\n cc += yyleng; ++wc; ++lc;
{ws}+ cc += yyleng;
\n+ cc += yyleng; lc += yyleng;
<<EOF>> {
printf( "%8d %8d %8d\n", lc, wc, cc );
yyterminate();
}
@@ -0,0 +1,25 @@
/* Somewhat faster still: potentially match a lot of text with each rule */
ws [ \t]
nonws [^ \t\n]
word {ws}*{nonws}+
words {word}{ws}+
%option main noyywrap
%%
int cc = 0, wc = 0, lc = 0;
{word}{ws}* cc += yyleng; ++wc;
{word}{ws}*\n cc += yyleng; ++wc; ++lc;
{words}{word}{ws}* cc += yyleng; wc += 2;
{words}{2}{word}{ws}* cc += yyleng; wc += 3;
{words}{3}{word}{ws}* cc += yyleng; wc += 4;
{ws}+ cc += yyleng;
\n+ cc += yyleng; lc += yyleng;
<<EOF>> {
printf( "%8d %8d %8d\n", lc, wc, cc );
yyterminate();
}
@@ -0,0 +1,28 @@
/* Fastest version of wc: add rules to pick up newlines, too */
ws [ \t]
nonws [^ \t\n]
word {ws}*{nonws}+
words {word}{ws}+
%option main noyywrap
%%
int cc = 0, wc = 0, lc = 0;
{word}{ws}* ++wc; cc += yyleng;
{word}{ws}*\n ++wc; cc += yyleng; ++lc;
{words}{word}{ws}* wc += 2; cc += yyleng;
{words}{word}{ws}*\n wc += 2; cc += yyleng; ++lc;
{words}{2}{word}{ws}* wc += 3; cc += yyleng;
{words}{2}{word}{ws}*\n wc += 3; cc += yyleng; ++lc;
{words}{3}{word}{ws}* wc += 4; cc += yyleng;
{words}{3}{word}{ws}*\n wc += 4; cc += yyleng; ++lc;
{ws}+ cc += yyleng;
\n+ cc += yyleng; lc += yyleng;
<<EOF>> {
printf( "%8d %8d %8d\n", lc, wc, cc );
yyterminate();
}
@@ -0,0 +1,25 @@
/* Oops; slight change from wc3.l introduces backtracking */
ws [ \t]
nonws [^ \t\n]
word {ws}*{nonws}+
words {word}{ws}+
%option main noyywrap
%%
int cc = 0, wc = 0, lc = 0;
{word}{ws}* cc += yyleng; ++wc;
{word}{ws}*\n cc += yyleng; ++wc; ++lc;
{words}{word} cc += yyleng; wc += 2; /* oops */
{words}{2}{word}{ws}* cc += yyleng; wc += 3;
{words}{3}{word}{ws}* cc += yyleng; wc += 4;
{ws}+ cc += yyleng;
\n+ cc += yyleng; lc += yyleng;
<<EOF>> {
printf( "%8d %8d %8d\n", lc, wc, cc );
yyterminate();
}
@@ -0,0 +1,24 @@
Tue Oct 5 21:51:59 1993 Vern Paxson
* Removed FILTER/ subdirectory.
* Removed alloca.c.
* Changed Makefile definition of CC to just "gcc -g", removed
assumption of alloca being present.
* Added pointer to MISC/fastwc/ to wc.lex.
Tue Jun 8 15:47:39 1993 Gavin Thomas Nicol (nick at sillybugs)
* Changed main() in wc.lex extensively. The old version would not
work correctly without the YY_NEW_FILE. (lex handles the older
version OK though).
* Added a rule to expr.lex to handle whitespace. The old version
reported an illegal character.
* Added -traditional to the gcc flags because the flex definition
for free() clashes with some systems that have old header files.
@@ -0,0 +1,55 @@
# 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.
EXTRA_DIST = \
ChangeLog \
Makefile.examples \
README \
cat.lex \
dates.lex \
datetest.dat \
eof_rules.lex \
eof_test01.txt \
eof_test02.txt \
eof_test03.txt \
expr.lex \
expr.y \
front.lex \
front.y \
j2t.lex \
myname.lex \
myname.txt \
myname2.lex \
numbers.lex \
pas_include.lex \
pascal.lex \
reject.lex \
replace.lex \
string1.lex \
string2.lex \
strtest.dat \
unput.lex \
user_act.lex \
userinit.lex \
wc.lex \
yymore.lex \
yymore2.lex \
yymoretest.dat
@@ -0,0 +1,88 @@
#############################################################
#
# Makefile : Makefile for Flex examples.
# Author : G.T.Nicol
# Last Updated : 1993/10/05
#
# If you use bison, you may have to supply an alloca
#
#############################################################
CC = gcc -g
LEX = flex -i -I
YACC = bison -d -y
ALLOCA =
############################################################
#
# DO NOT CHANGE ANYTHING FROM HERE ON !!!!!!!!!
#
############################################################
all: expr front myname eof wc replace user_act string1\
string2 yymore numbers dates cat
expr: expr.y expr.lex
$(YACC) expr.y
$(LEX) expr.lex
$(CC) -o expr lex.yy.c y.tab.c $(ALLOCA) -ll -lm
front: front.y front.lex
$(YACC) front.y
$(LEX) front.lex
$(CC) -o front lex.yy.c y.tab.c $(ALLOCA) -ll -lm
numbers: numbers.lex
$(LEX) numbers.lex
$(CC) lex.yy.c -o numbers
dates: dates.lex
$(LEX) dates.lex
$(CC) lex.yy.c -o dates -ll
yymore: yymore.lex
$(LEX) yymore.lex
$(CC) lex.yy.c -o yymore -ll
string1: string1.lex
$(LEX) string1.lex
$(CC) lex.yy.c -o string1 -ll
string2: string2.lex
$(LEX) string2.lex
$(CC) lex.yy.c -o string2 -ll
myname: myname.lex
$(LEX) myname.lex
$(CC) lex.yy.c -o myname -ll
myname2: myname2.lex
$(LEX) myname2.lex
$(CC) lex.yy.c -o myname2 -ll
eof: eof_rules.lex
$(LEX) eof_rules.lex
$(CC) lex.yy.c -o eof -ll
wc: wc.lex
$(LEX) wc.lex
$(CC) lex.yy.c -o wc -ll
cat: cat.lex
$(LEX) cat.lex
$(CC) lex.yy.c -o cat -ll
replace: replace.lex
$(LEX) replace.lex
$(CC) lex.yy.c -o replace -ll
user_act: expr.y expr.lex
$(LEX) user_act.lex
$(CC) -o user_act lex.yy.c -ll
clean:
rm -f *.BAK *.o core *~* *.a
rm -f *.tab.h *.tab.c
rm -f myname expr lex.yy.c *.out eof wc yymore
rm -f replace front user_act string1 string2
rm -f dates numbers cat
@@ -0,0 +1,539 @@
# Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
# 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.
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = examples/manual
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_cc_for_build.m4 \
$(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/iconv.m4 \
$(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/lib-ld.m4 \
$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
$(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
SOURCES =
DIST_SOURCES =
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
am__DIST_COMMON = $(srcdir)/Makefile.in ChangeLog README
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
ALLOCA = @ALLOCA@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BUILD_EXEEXT = @BUILD_EXEEXT@
BUILD_OBJEXT = @BUILD_OBJEXT@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CC_FOR_BUILD = @CC_FOR_BUILD@
CFLAGS = @CFLAGS@
CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@
CPP_FOR_BUILD = @CPP_FOR_BUILD@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
GMSGFMT = @GMSGFMT@
GMSGFMT_015 = @GMSGFMT_015@
GREP = @GREP@
HELP2MAN = @HELP2MAN@
INDENT = @INDENT@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTLLIBS = @INTLLIBS@
INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
LD = @LD@
LDFLAGS = @LDFLAGS@
LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@
LEX = @LEX@
LEXLIB = @LEXLIB@
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
LIBICONV = @LIBICONV@
LIBINTL = @LIBINTL@
LIBOBJS = @LIBOBJS@
LIBPTHREAD = @LIBPTHREAD@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBICONV = @LTLIBICONV@
LTLIBINTL = @LTLIBINTL@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
M4 = @M4@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MSGFMT = @MSGFMT@
MSGFMT_015 = @MSGFMT_015@
MSGMERGE = @MSGMERGE@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
POSUB = @POSUB@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
SHELL = @SHELL@
STRIP = @STRIP@
TEXI2DVI = @TEXI2DVI@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
WARNINGFLAGS = @WARNINGFLAGS@
XGETTEXT = @XGETTEXT@
XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
YACC = @YACC@
YFLAGS = @YFLAGS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CC_FOR_BUILD = @ac_ct_CC_FOR_BUILD@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
EXTRA_DIST = \
ChangeLog \
Makefile.examples \
README \
cat.lex \
dates.lex \
datetest.dat \
eof_rules.lex \
eof_test01.txt \
eof_test02.txt \
eof_test03.txt \
expr.lex \
expr.y \
front.lex \
front.y \
j2t.lex \
myname.lex \
myname.txt \
myname2.lex \
numbers.lex \
pas_include.lex \
pascal.lex \
reject.lex \
replace.lex \
string1.lex \
string2.lex \
strtest.dat \
unput.lex \
user_act.lex \
userinit.lex \
wc.lex \
yymore.lex \
yymore2.lex \
yymoretest.dat
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign examples/manual/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign examples/manual/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
tags TAGS:
ctags CTAGS:
cscope cscopelist:
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am:
.MAKE: install-am install-strip
.PHONY: all all-am check check-am clean clean-generic clean-libtool \
cscopelist-am ctags-am distclean distclean-generic \
distclean-libtool distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags-am uninstall uninstall-am
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
@@ -0,0 +1,12 @@
This directory contains the example programs from the manual, and a
few other things as well. To make all the programs, simply type "make
-f Makefile.examples", and assuming you have flex and gcc, all will be
well.
To build the programs individually, type
make -f Makefile.examples program_name
For example:
make -f Makefile.examples expr
@@ -0,0 +1,45 @@
/*
* cat.lex: A demonstration of YY_NEW_FILE.
*/
%{
#include <stdio.h>
char **names = NULL;
int current = 1;
%}
%%
<<EOF>> {
current += 1;
if(names[current] != NULL){
yyin = fopen(names[current],"r");
if(yyin == NULL){
fprintf(stderr,"cat: unable to open %s\n",
names[current]);
yyterminate();
}
YY_NEW_FILE;
} else {
yyterminate();
}
}
%%
int main(int argc, char **argv)
{
if(argc < 2){
fprintf(stderr,"Usage: cat files....\n");
exit(1);
}
names = argv;
yyin = fopen(names[current],"r");
if(yyin == NULL){
fprintf(stderr,"cat: unable to open %s\n",
names[current]);
yyterminate();
}
yylex();
}
@@ -0,0 +1,106 @@
/*
* dates.lex: An example of using start states to
* distinguish between different date formats.
*/
%{
#include <ctype.h>
char month[20],dow[20],day[20],year[20];
%}
skip of|the|[ \t,]*
mon (mon(day)?)
tue (tue(sday)?)
wed (wed(nesday)?)
thu (thu(rsday)?)
fri (fri(day)?)
sat (sat(urday)?)
sun (sun(day)?)
day_of_the_week ({mon}|{tue}|{wed}|{thu}|{fri}|{sat}|{sun})
jan (jan(uary)?)
feb (feb(ruary)?)
mar (mar(ch)?)
apr (apr(il)?)
may (may)
jun (jun(e)?)
jul (jul(y)?)
aug (aug(ust)?)
sep (sep(tember)?)
oct (oct(ober)?)
nov (nov(ember)?)
dec (dec(ember)?)
first_half ({jan}|{feb}|{mar}|{apr}|{may}|{jun})
second_half ({jul}|{aug}|{sep}|{oct}|{nov}|{dec})
month {first_half}|{second_half}
nday [1-9]|[1-2][0-9]|3[0-1]
nmonth [1-9]|1[0-2]
nyear [0-9]{1,4}
year_ext (ad|AD|bc|BC)?
day_ext (st|nd|rd|th)?
%s LONG SHORT
%s DAY DAY_FIRST YEAR_FIRST YEAR_LAST YFMONTH YLMONTH
%%
/* the default is month-day-year */
<LONG>{day_of_the_week} strcpy(dow,yytext);
<LONG>{month} strcpy(month,yytext); BEGIN(DAY);
/* handle the form: day-month-year */
<LONG>{nday}{day_ext} strcpy(day,yytext); BEGIN(DAY_FIRST);
<DAY_FIRST>{month} strcpy(month,yytext); BEGIN(LONG);
<DAY>{nday}{day_ext} strcpy(day,yytext); BEGIN(LONG);
<LONG>{nyear}{year_ext} {
printf("Long:\n");
printf(" DOW : %s \n",dow);
printf(" Day : %s \n",day);
printf(" Month : %s \n",month);
printf(" Year : %s \n",yytext);
strcpy(dow,"");
strcpy(day,"");
strcpy(month,"");
}
/* handle dates of the form: day-month-year */
<SHORT>{nday} strcpy(day,yytext); BEGIN(YEAR_LAST);
<YEAR_LAST>{nmonth} strcpy(month,yytext);BEGIN(YLMONTH);
<YLMONTH>{nyear} strcpy(year,yytext); BEGIN(SHORT);
/* handle dates of the form: year-month-day */
<SHORT>{nyear} strcpy(year,yytext); BEGIN(YEAR_FIRST);
<YEAR_FIRST>{nmonth} strcpy(month,yytext);BEGIN(YFMONTH);
<YFMONTH>{nday} strcpy(day,yytext); BEGIN(SHORT);
<SHORT>\n {
printf("Short:\n");
printf(" Day : %s \n",day);
printf(" Month : %s \n",month);
printf(" Year : %s \n",year);
strcpy(year,"");
strcpy(day,"");
strcpy(month,"");
}
long\n BEGIN(LONG);
short\n BEGIN(SHORT);
{skip}*
\n
.
@@ -0,0 +1,28 @@
short
1989:12:23
1989:11:12
23:12:1989
11:12:1989
1989/12/23
1989/11/12
23/12/1989
11/12/1989
1989-12-23
1989-11-12
23-12-1989
11-12-1989
long
Friday the 5th of January, 1989
Friday, 5th of January, 1989
Friday, January 5th, 1989
Fri, January 5th, 1989
Fri, Jan 5th, 1989
Fri, Jan 5, 1989
FriJan 5, 1989
FriJan5, 1989
FriJan51989
Jan51989
@@ -0,0 +1,65 @@
/*
* eof_rules.lex : An example of using multiple buffers
* EOF rules, and start states
*/
%{
#define MAX_NEST 10
YY_BUFFER_STATE include_stack[MAX_NEST];
int include_count = -1;
%}
%x INCLUDE
%%
^"#include"[ \t]*\" BEGIN(INCLUDE);
<INCLUDE>\" BEGIN(INITIAL);
<INCLUDE>[^\"]+ { /* get the include file name */
if ( include_count >= MAX_NEST){
fprintf( stderr, "Too many include files" );
exit( 1 );
}
include_stack[++include_count] = YY_CURRENT_BUFFER;
yyin = fopen( yytext, "r" );
if ( ! yyin ){
fprintf( stderr, "Unable to open \"%s\"\n",yytext);
exit( 1 );
}
yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE));
BEGIN(INITIAL);
}
<INCLUDE><<EOF>>
{
fprintf( stderr, "EOF in include" );
yyterminate();
}
<<EOF>> {
if ( include_count <= 0 ){
yyterminate();
} else {
yy_delete_buffer(include_stack[include_count--] );
yy_switch_to_buffer(include_stack[include_count] );
BEGIN(INCLUDE);
}
}
[a-z]+ ECHO;
.|\n ECHO;
@@ -0,0 +1,17 @@
This is test file #1
-------------------------------------------------
We will now include test #2 in a standard way.
#include "eof_test02.txt"
-------------------------------------------------
And now we will include test # 2 with a different
format
#include "eof_test02.txt"
-------------------------------------------------
and this is the end of the test.
@@ -0,0 +1,8 @@
INCLUDE #2
This is the second file that will
be included.
>>> Foo are GNU?
#include "eof_test03.txt"
@@ -0,0 +1,7 @@
INCLUDE #3
This is the third file that will
be included.
>>> echo "I am `whoami`!!"
@@ -0,0 +1,35 @@
/*
* expr.lex : Scanner for a simple
* expression parser.
*/
%{
#include "y.tab.h"
%}
%%
[0-9]+ { yylval.val = atol(yytext);
return(NUMBER);
}
[0-9]+\.[0-9]+ {
sscanf(yytext,"%f",&yylval.val);
return(NUMBER);
}
"+" return(PLUS);
"-" return(MINUS);
"*" return(MULT);
"/" return(DIV);
"^" return(EXPON);
"(" return(LB);
")" return(RB);
\n return(EOL);
[\t ]* /* throw away whitespace */
. { yyerror("Illegal character");
return(EOL);
}
%%
@@ -0,0 +1,64 @@
/*
* expr.y : A simple yacc expression parser
* Based on the Bison manual example.
*/
%{
#include <stdio.h>
#include <math.h>
%}
%union {
float val;
}
%token NUMBER
%token PLUS MINUS MULT DIV EXPON
%token EOL
%token LB RB
%left MINUS PLUS
%left MULT DIV
%right EXPON
%type <val> exp NUMBER
%%
input :
| input line
;
line : EOL
| exp EOL { printf("%g\n",$1);}
exp : NUMBER { $$ = $1; }
| exp PLUS exp { $$ = $1 + $3; }
| exp MINUS exp { $$ = $1 - $3; }
| exp MULT exp { $$ = $1 * $3; }
| exp DIV exp { $$ = $1 / $3; }
| MINUS exp %prec MINUS { $$ = -$2; }
| exp EXPON exp { $$ = pow($1,$3);}
| LB exp RB { $$ = $2; }
;
%%
yyerror(char *message)
{
printf("%s\n",message);
}
int main(int argc, char *argv[])
{
yyparse();
return(0);
}
@@ -0,0 +1,40 @@
%{
#include <stdio.h>
#include <string.h>
#include "y.tab.h" /* this comes from bison */
#define TRUE 1
#define FALSE 0
#define copy_and_return(token_type) { strcpy(yylval.name,yytext); \
return(token_type); }
int yylexlinenum = 0; /* so we can count lines */
%}
%%
/* Lexical scanning rules begin from here. */
MEN|WOMEN|STOCKS|TREES copy_and_return(NOUN)
MISTAKES|GNUS|EMPLOYEES copy_and_return(NOUN)
LOSERS|USERS|CARS|WINDOWS copy_and_return(NOUN)
DATABASE|NETWORK|FSF|GNU copy_and_return(PROPER_NOUN)
COMPANY|HOUSE|OFFICE|LPF copy_and_return(PROPER_NOUN)
THE|THIS|THAT|THOSE copy_and_return(DECLARATIVE)
ALL|FIRST|LAST copy_and_return(CONDITIONAL)
FIND|SEARCH|SORT|ERASE|KILL copy_and_return(VERB)
ADD|REMOVE|DELETE|PRINT copy_and_return(VERB)
QUICKLY|SLOWLY|CAREFULLY copy_and_return(ADVERB)
IN|AT|ON|AROUND|INSIDE|ON copy_and_return(POSITIONAL)
"." return(PERIOD);
"\n" yylexlinenum++; return(NEWLINE);
.
%%
@@ -0,0 +1,118 @@
/* C code supplied at the beginning of the file. */
%{
#include <stdio.h>
#include <string.h>
extern int yylexlinenum; /* these are in YYlex */
extern char *yytext; /* current token */
%}
/* Keywords and reserved words begin here. */
%union{ /* this is the data union */
char name[128]; /* names */
}
/*-------------------- the reserved words -----------------------------*/
%token PERIOD
%token NEWLINE
%token POSITIONAL
%token VERB
%token ADVERB
%token PROPER_NOUN
%token NOUN
%token DECLARATIVE
%token CONDITIONAL
%type <name> declarative
%type <name> verb_phrase
%type <name> noun_phrase
%type <name> position_phrase
%type <name> adverb
%type <name> POSITIONAL VERB ADVERB PROPER_NOUN
%type <name> NOUN DECLARATIVE CONDITIONAL
%%
sentence_list : sentence
| sentence_list NEWLINE sentence
;
sentence : verb_phrase noun_phrase position_phrase adverb period
{
printf("I understand that sentence.\n");
printf("VP = %s \n",$1);
printf("NP = %s \n",$2);
printf("PP = %s \n",$3);
printf("AD = %s \n",$4);
}
| { yyerror("That's a strange sentence !!"); }
;
position_phrase : POSITIONAL declarative PROPER_NOUN
{
sprintf($$,"%s %s %s",$1,$2,$3);
}
| /* empty */ { strcpy($$,""); }
;
verb_phrase : VERB { strcpy($$,$1); strcat($$," "); }
| adverb VERB
{
sprintf($$,"%s %s",$1,$2);
}
;
adverb : ADVERB { strcpy($$,$1); }
| /* empty */ { strcpy($$,""); }
;
noun_phrase : DECLARATIVE NOUN
{
sprintf($$,"%s %s",$1,$2);
}
| CONDITIONAL declarative NOUN
{
sprintf($$,"%s %s %s",$1,$2,$3);
}
| NOUN { strcpy($$,$1); strcat($$," "); }
;
declarative : DECLARATIVE { strcpy($$,$1); }
| /* empty */ { strcpy($$,""); }
;
period : /* empty */
| PERIOD
;
%%
/* Supplied main() and yyerror() functions. */
int main(int argc, char *argv[])
{
yyparse(); /* parse the file */
return(0);
}
int yyerror(char *message)
{
extern FILE *yyout;
fprintf(yyout,"\nError at line %5d. (%s) \n",
yylexlinenum,message);
}
@@ -0,0 +1,442 @@
/*
* j2t.lex : An example of the use (possibly abuse!)
* of start states.
*/
%{
#define MAX_STATES 1024
#define TRUE 1
#define FALSE 0
#define CHAPTER "@chapter"
#define SECTION "@section"
#define SSECTION "@subsection"
#define SSSECTION "@subsubsection"
int states[MAX_STATES];
int statep = 0;
int need_closing = FALSE;
char buffer[YY_BUF_SIZE];
extern char *yytext;
/*
* set up the head of the *.texinfo file the program
* will produce. This is a standard texinfo header.
*/
void print_header(void)
{
printf("\\input texinfo @c -*-texinfo-*-\n");
printf("@c %c**start of header\n",'%');
printf("@setfilename jargon.info\n");
printf("@settitle The New Hackers Dictionary\n");
printf("@synindex fn cp\n");
printf("@synindex vr cp\n");
printf("@c %c**end of header\n",'%');
printf("@setchapternewpage odd\n");
printf("@finalout\n");
printf("@c @smallbook\n");
printf("\n");
printf("@c ==========================================================\n\n");
printf("@c This file was produced by j2t. Any mistakes are *not* the\n");
printf("@c fault of the jargon file editors. \n");
printf("@c ==========================================================\n\n");
printf("@titlepage\n");
printf("@title The New Hackers Dictionary\n");
printf("@subtitle Version 2.9.10\n");
printf("@subtitle Generated by j2t\n");
printf("@author Eric S. Raymond, Guy L. Steel, Mark Crispin et al.\n");
printf("@end titlepage\n");
printf("@page\n");
printf("\n@c ==========================================================\n");
printf("\n\n");
printf("@unnumbered Preface\n");
printf("@c *******\n");
}
/*
* create the tail of the texinfo file produced.
*/
void print_trailer(void)
{
printf("\n@c ==========================================================\n");
printf("@contents\n"); /* print the table of contents */
printf("@bye\n\n");
}
/*
* write an underline under a section
* or chapter so we can find it later.
*/
void write_underline(int len, int space, char ch)
{
int loop;
printf("@c ");
for(loop=3; loop<space; loop++){
printf(" ");
}
while(len--){
printf("%c",ch);
}
printf("\n\n");
}
/*
* check for texinfo special characters
* and escape them
*/
char *check_and_convert(char *string)
{
int buffpos = 0;
int len,loop;
len = strlen(string);
for(loop=0; loop<len; loop++){
if(string[loop] == '@' || string[loop] == '{' || string[loop] == '}'){
buffer[buffpos++] = '@';
buffer[buffpos++] = string[loop];
} else {
buffer[buffpos++] = string[loop];
}
}
buffer[buffpos] = '\0';
return(buffer);
}
/*
* write out a chapter,section, or subsection
* header
*/
void write_block_header(char *type)
{
int loop;
int len;
(void)check_and_convert(yytext);
len = strlen(buffer);
for(loop=0; buffer[loop] != '\n';loop++)
;
buffer[loop] = '\0';
printf("%s %s\n",type,buffer);
write_underline(strlen(buffer),strlen(type)+1,'*');
}
%}
/*
* the flex description starts here
*/
%x HEADING EXAMPLE ENUM EXAMPLE2
%x BITEM BITEM_ITEM
%s LITEM LITEM2
%%
^#[^#]*"#" /* skip the header & trailer */
/* chapters have asterisks under them
* and are terminated by a colon
*/
^[^\n:]+\n[*]+\n write_block_header(CHAPTER);
^"= "[A-Z]" ="\n"="* { /* we create a seciton for each category */
if(need_closing == TRUE){
printf("@end table\n\n\n");
}
need_closing = TRUE;
write_block_header(SECTION);
printf("\n\n@table @b\n");
}
"Examples:"[^\.]+ ECHO;
"*"[^*\n]+"*" { /* @emph{}(emphasized) text */
yytext[yyleng-1] = '\0';
(void)check_and_convert(&yytext[1]);
printf("@i{%s}",buffer);
}
"{{"[^}]+"}}" { /* special emphasis */
yytext[yyleng-2] = '\0';
(void)check_and_convert(&yytext[2]);
printf("@b{%s}",buffer);
}
"{"[^}]+"}" { /* special emphasis */
yytext[yyleng-1] = '\0';
(void)check_and_convert(&yytext[1]);
printf("@b{%s}",buffer);
}
/* escape some special texinfo characters */
<INITIAL,LITEM,LITEM2,BITEM,ENUM,EXAMPLE,EXAMPLE2>"@" printf("@@");
<INITIAL,LITEM,LITEM2,BITEM,ENUM,EXAMPLE,EXAMPLE2>"{" printf("@{");
<INITIAL,LITEM,LITEM2,BITEM,ENUM,EXAMPLE,EXAMPLE2>"}" printf("@}");
/*
* reproduce @example code
*/
":"\n+[^\n0-9*]+\n" "[^ ] {
int loop;
int len;
int cnt;
printf(":\n\n@example \n");
strcpy(buffer,yytext);
len = strlen(buffer);
cnt = 0;
for(loop=len; loop > 0;loop--){
if(buffer[loop] == '\n')
cnt++;
if(cnt == 2)
break;
}
yyless(loop+1);
statep++;
states[statep] = EXAMPLE2;
BEGIN(EXAMPLE2);
}
<EXAMPLE,EXAMPLE2>^\n {
printf("@end example\n\n");
statep--;
BEGIN(states[statep]);
}
/*
* repoduce @enumerate lists
*/
":"\n+[ \t]*[0-9]+"." {
int loop;
int len;
printf(":\n\n@enumerate \n");
strcpy(buffer,yytext);
len = strlen(buffer);
for(loop=len; loop > 0;loop--){
if(buffer[loop] == '\n')
break;
}
yyless(loop);
statep++;
states[statep] = ENUM;
BEGIN(ENUM);
}
<ENUM>"@" printf("@@");
<ENUM>":"\n+" "[^0-9] {
printf(":\n\n@example\n");
statep++;
states[statep] = EXAMPLE;
BEGIN(EXAMPLE);
}
<ENUM>\n[ \t]+[0-9]+"." {
printf("\n\n@item ");
}
<ENUM>^[^ ] |
<ENUM>\n\n\n[ \t]+[^0-9] {
printf("\n\n@end enumerate\n\n");
statep--;
BEGIN(states[statep]);
}
/*
* reproduce one kind of @itemize list
*/
":"\n+":" {
int loop;
int len;
printf(":\n\n@itemize @bullet \n");
yyless(2);
statep++;
states[statep] = LITEM2;
BEGIN(LITEM2);
}
<LITEM2>^":".+":" {
(void)check_and_convert(&yytext[1]);
buffer[strlen(buffer)-1]='\0';
printf("@item @b{%s:}\n",buffer);
}
<LITEM2>\n\n\n+[^:\n] {
printf("\n\n@end itemize\n\n");
ECHO;
statep--;
BEGIN(states[statep]);
}
/*
* create a list out of the revision history part.
* We need the "Version" for this because it
* clashes with other rules otherwise.
*/
:[\n]+"Version"[^:\n*]+":" {
int loop;
int len;
printf(":\n\n@itemize @bullet \n");
strcpy(buffer,yytext);
len = strlen(buffer);
for(loop=len; loop > 0;loop--){
if(buffer[loop] == '\n')
break;
}
yyless(loop);
statep++;
states[statep] = LITEM;
BEGIN(LITEM);
}
<LITEM>^.+":" {
(void)check_and_convert(yytext);
buffer[strlen(buffer)-1]='\0';
printf("@item @b{%s}\n\n",buffer);
}
<LITEM>^[^:\n]+\n\n[^:\n]+\n {
int loop;
strcpy(buffer,yytext);
for(loop=0; buffer[loop] != '\n'; loop++);
buffer[loop] = '\0';
printf("%s\n",buffer);
printf("@end itemize\n\n");
printf("%s",&buffer[loop+1]);
statep--;
BEGIN(states[statep]);
}
/*
* reproduce @itemize @bullet lists
*/
":"\n[ ]*"*" {
int loop;
int len;
printf(":\n\n@itemize @bullet \n");
len = strlen(buffer);
for(loop=0; loop < len;loop++){
if(buffer[loop] == '\n')
break;
}
yyless((len-loop)+2);
statep++;
states[statep] = BITEM;
BEGIN(BITEM);
}
<BITEM>^" "*"*" {
printf("@item");
statep++;
states[statep] = BITEM_ITEM;
BEGIN(BITEM_ITEM);
}
<BITEM>"@" printf("@@");
<BITEM>^\n {
printf("@end itemize\n\n");
statep--;
BEGIN(states[statep]);
}
<BITEM_ITEM>[^\:]* {
printf(" @b{%s}\n\n",check_and_convert(yytext));
}
<BITEM_ITEM>":" {
statep--;
BEGIN(states[statep]);
}
/*
* recreate @chapter, @section etc.
*/
^:[^:]* {
(void)check_and_convert(&yytext[1]);
statep++;
states[statep] = HEADING;
BEGIN(HEADING);
}
<HEADING>:[^\n] {
printf("@item @b{%s}\n",buffer);
write_underline(strlen(buffer),6,'~');
statep--;
BEGIN(states[statep]);
}
<HEADING>:\n"*"* {
if(need_closing == TRUE){
printf("@end table\n\n\n");
need_closing = FALSE;
}
printf("@chapter %s\n",buffer);
write_underline(strlen(buffer),9,'*');
statep--;
BEGIN(states[statep]);
}
<HEADING>:\n"="* {
if(need_closing == TRUE){
printf("@end table\n\n\n");
need_closing = FALSE;
}
printf("@section %s\n",buffer);
write_underline(strlen(buffer),9,'=');
statep--;
BEGIN(states[statep]);
}
<HEADING>"@" printf("@@");
<HEADING>:\n"-"* {
if(need_closing == TRUE){
printf("@end table\n\n\n");
need_closing = FALSE;
}
printf("@subsection %s\n",buffer);
write_underline(strlen(buffer),12,'-');
statep--;
BEGIN(states[statep]);
}
/*
* recreate @example text
*/
^" " {
printf("@example\n");
statep++;
states[statep] = EXAMPLE;
BEGIN(EXAMPLE);
}
<EXAMPLE>^" "
. ECHO;
%%
/*
* initialise and go.
*/
int main(int argc, char *argv[])
{
states[0] = INITIAL;
statep = 0;
print_header();
yylex();
print_trailer();
return(0);
}
@@ -0,0 +1,15 @@
/*
*
* myname.lex : A sample Flex program
* that does token replacement.
*/
%%
%NAME { printf("%s",getenv("LOGNAME")); }
%HOST { printf("%s",getenv("HOST")); }
%HOSTTYPE { printf("%s",getenv("HOSTTYPE"));}
%HOME { printf("%s",getenv("HOME")); }
%%
@@ -0,0 +1,6 @@
Hello, my name name is %NAME. Actually
"%NAME" isn't my real name, it is the
alias I use when I'm on %HOST, which
is the %HOSTTYPE I use. My HOME
directory is %HOME.
@@ -0,0 +1,19 @@
/*
* myname2.lex : A sample Flex program
* that does token replacement.
*/
%{
#include <stdio.h>
%}
%x STRING
%%
\" ECHO; BEGIN(STRING);
<STRING>[^\"\n]* ECHO;
<STRING>\" ECHO; BEGIN(INITIAL);
%NAME { printf("%s",getenv("LOGNAME")); }
%HOST { printf("%s",getenv("HOST")); }
%HOSTTYPE { printf("%s",getenv("HOSTTYPE"));}
%HOME { printf("%s",getenv("HOME")); }
@@ -0,0 +1,145 @@
/*
* numbers.lex : An example of the definitions and techniques
* for scanning numbers
*/
%{
#include <stdio.h>
#define UNSIGNED_LONG_SYM 1
#define SIGNED_LONG_SYM 2
#define UNSIGNED_SYM 3
#define SIGNED_SYM 4
#define LONG_DOUBLE_SYM 5
#define FLOAT_SYM 6
union _yylval {
long double ylong_double;
float yfloat;
unsigned long yunsigned_long;
unsigned yunsigned;
long ysigned_long;
int ysigned;
} yylval;
%}
digit [0-9]
hex_digit [0-9a-fA-F]
oct_digit [0-7]
exponent [eE][+-]?{digit}+
i {digit}+
float_constant ({i}\.{i}?|{i}?\.{i}){exponent}?
hex_constant 0[xX]{hex_digit}+
oct_constant 0{oct_digit}*
int_constant {digit}+
long_ext [lL]
unsigned_ext [uU]
float_ext [fF]
ulong_ext {long_ext}{unsigned_ext}|{unsigned_ext}{long_ext}
%%
{hex_constant}{ulong_ext} { /* we need to skip the "0x" part */
sscanf(&yytext[2],"%lx",&yylval.yunsigned_long);
return(UNSIGNED_LONG_SYM);
}
{hex_constant}{long_ext} {
sscanf(&yytext[2],"%lx",&yylval.ysigned_long);
return(SIGNED_LONG_SYM);
}
{hex_constant}{unsigned_ext} {
sscanf(&yytext[2],"%x",&yylval.yunsigned);
return(UNSIGNED_SYM);
}
{hex_constant} { /* use %lx to protect against overflow */
sscanf(&yytext[2],"%lx",&yylval.ysigned_long);
return(SIGNED_LONG_SYM);
}
{oct_constant}{ulong_ext} {
sscanf(yytext,"%lo",&yylval.yunsigned_long);
return(UNSIGNED_LONG_SYM);
}
{oct_constant}{long_ext} {
sscanf(yytext,"%lo",&yylval.ysigned_long);
return(SIGNED_LONG_SYM);
}
{oct_constant}{unsigned_ext} {
sscanf(yytext,"%o",&yylval.yunsigned);
return(UNSIGNED_SYM);
}
{oct_constant} { /* use %lo to protect against overflow */
sscanf(yytext,"%lo",&yylval.ysigned_long);
return(SIGNED_LONG_SYM);
}
{int_constant}{ulong_ext} {
sscanf(yytext,"%ld",&yylval.yunsigned_long);
return(UNSIGNED_LONG_SYM);
}
{int_constant}{long_ext} {
sscanf(yytext,"%ld",&yylval.ysigned_long);
return(SIGNED_LONG_SYM);
}
{int_constant}{unsigned_ext} {
sscanf(yytext,"%d",&yylval.yunsigned);
return(UNSIGNED_SYM);
}
{int_constant} { /* use %ld to protect against overflow */
sscanf(yytext,"%ld",&yylval.ysigned_long);
return(SIGNED_LONG_SYM);
}
{float_constant}{long_ext} {
sscanf(yytext,"%lf",&yylval.ylong_double);
return(LONG_DOUBLE_SYM);
}
{float_constant}{float_ext} {
sscanf(yytext,"%f",&yylval.yfloat);
return(FLOAT_SYM);
}
{float_constant} { /* use %lf to protect against overflow */
sscanf(yytext,"%lf",&yylval.ylong_double);
return(LONG_DOUBLE_SYM);
}
%%
int main(void)
{
int code;
while((code = yylex())){
printf("yytext : %s\n",yytext);
switch(code){
case UNSIGNED_LONG_SYM:
printf("Type of number : UNSIGNED LONG\n");
printf("Value of number : %lu\n",yylval.yunsigned_long);
break;
case SIGNED_LONG_SYM:
printf("Type of number : SIGNED LONG\n");
printf("Value of number : %ld\n",yylval.ysigned_long);
break;
case UNSIGNED_SYM:
printf("Type of number : UNSIGNED\n");
printf("Value of number : %u\n",yylval.yunsigned);
break;
case SIGNED_SYM:
printf("Type of number : SIGNED\n");
printf("Value of number : %d\n",yylval.ysigned);
break;
case LONG_DOUBLE_SYM:
printf("Type of number : LONG DOUBLE\n");
printf("Value of number : %lf\n",yylval.ylong_double);
break;
case FLOAT_SYM:
printf("Type of number : FLOAT\n");
printf("Value of number : %f\n",yylval.yfloat);
break;
default:
printf("Type of number : UNDEFINED\n");
printf("Value of number : UNDEFINED\n");
break;
}
}
return(0);
}
@@ -0,0 +1,78 @@
/*
* eof_rules.lex : An example of using multiple buffers
* EOF rules, and start states
*/
%{
#define MAX_NEST 10
YY_BUFFER_STATE include_stack[MAX_NEST];
int include_count = -1;
%}
%x INCLUDE
%x COMMENT
%%
"{" BEGIN(COMMENT);
<COMMENT>"}" BEGIN(INITIAL);
<COMMENT>"$include"[ \t]*"(" BEGIN(INCLUDE);
<COMMENT>[ \t]* /* skip whitespace */
<INCLUDE>")" BEGIN(COMMENT);
<INCLUDE>[ \t]* /* skip whitespace */
<INCLUDE>[^ \t\n() ]+ { /* get the include file name */
if ( include_count >= MAX_NEST){
fprintf( stderr, "Too many include files" );
exit( 1 );
}
include_stack[++include_count] = YY_CURRENT_BUFFER;
yyin = fopen( yytext, "r" );
if ( ! yyin ){
fprintf( stderr, "Unable to open %s",yytext);
exit( 1 );
}
yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE));
BEGIN(INITIAL);
}
<INCLUDE><<EOF>>
{
fprintf( stderr, "EOF in include" );
yyterminate();
}
<COMMENT><<EOF>>
{
fprintf( stderr, "EOF in comment" );
yyterminate();
}
<<EOF>> {
if ( include_count <= 0 ){
yyterminate();
} else {
yy_delete_buffer(include_stack[include_count--] );
yy_switch_to_buffer(include_stack[include_count] );
BEGIN(INCLUDE);
}
}
[a-z]+ ECHO;
.|\n ECHO;
@@ -0,0 +1,120 @@
/*
* pascal.lex: An example PASCAL scanner
*
*/
%{
#include <stdio.h>
#include "y.tab.h"
int line_number = 0;
void yyerror(char *message);
%}
%x COMMENT1 COMMENT2
white_space [ \t]*
digit [0-9]
alpha [A-Za-z_]
alpha_num ({alpha}|{digit})
hex_digit [0-9A-F]
identifier {alpha}{alpha_num}*
unsigned_integer {digit}+
hex_integer ${hex_digit}{hex_digit}*
exponent e[+-]?{digit}+
i {unsigned_integer}
real ({i}\.{i}?|{i}?\.{i}){exponent}?
string \'([^'\n]|\'\')+\'
bad_string \'([^'\n]|\'\')+
%%
"{" BEGIN(COMMENT1);
<COMMENT1>[^}\n]+
<COMMENT1>\n ++line_number;
<COMMENT1><<EOF>> yyerror("EOF in comment");
<COMMENT1>"}" BEGIN(INITIAL);
"(*" BEGIN(COMMENT2);
<COMMENT2>[^)*\n]+
<COMMENT2>\n ++line_number;
<COMMENT2><<EOF>> yyerror("EOF in comment");
<COMMENT2>"*)" BEGIN(INITIAL);
<COMMENT2>[*)]
/* note that FILE and BEGIN are already
* defined in FLEX or C so they can't
* be used. This can be overcome in
* a cleaner way by defining all the
* tokens to start with TOK_ or some
* other prefix.
*/
and return(AND);
array return(ARRAY);
begin return(_BEGIN);
case return(CASE);
const return(CONST);
div return(DIV);
do return(DO);
downto return(DOWNTO);
else return(ELSE);
end return(END);
file return(_FILE);
for return(FOR);
function return(FUNCTION);
goto return(GOTO);
if return(IF);
in return(IN);
label return(LABEL);
mod return(MOD);
nil return(NIL);
not return(NOT);
of return(OF);
packed return(PACKED);
procedure return(PROCEDURE);
program return(PROGRAM);
record return(RECORD);
repeat return(REPEAT);
set return(SET);
then return(THEN);
to return(TO);
type return(TYPE);
until return(UNTIL);
var return(VAR);
while return(WHILE);
with return(WITH);
"<="|"=<" return(LEQ);
"=>"|">=" return(GEQ);
"<>" return(NEQ);
"=" return(EQ);
".." return(DOUBLEDOT);
{unsigned_integer} return(UNSIGNED_INTEGER);
{real} return(REAL);
{hex_integer} return(HEX_INTEGER);
{string} return{STRING};
{bad_string} yyerror("Unterminated string");
{identifier} return(IDENTIFIER);
[*/+\-,^.;:()\[\]] return(yytext[0]);
{white_space} /* do nothing */
\n line_number += 1;
. yyerror("Illegal input");
%%
void yyerror(char *message)
{
fprintf(stderr,"Error: \"%s\" in line %d. Token = %s\n",
message,line_number,yytext);
exit(1);
}
@@ -0,0 +1,12 @@
/*
* reject.lex: An example of REJECT and unput()
* misuse.
*/
%%
UNIX {
unput('U'); unput('N'); unput('G'); unput('\0');
REJECT;
}
GNU printf("GNU is Not Unix!\n");
%%
@@ -0,0 +1,33 @@
/*
* replace.lex : A simple filter for renaming
* parts of flex of bison generated
* scanners or parsers.
*/
%{
#include <stdio.h>
char lower_replace[1024];
char upper_replace[1024];
%}
%%
"yy" printf("%s",lower_replace);
"YY" printf("%s",upper_replace);
, ECHO;
%%
int main(int argc, char *argv[])
{
if(argc < 2){
printf("Usage %s lower UPPER\n",argv[0]);
exit(1);
}
strcpy(lower_replace,argv[1]);
strcpy(upper_replace,argv[2]);
yylex();
return(0);
}
@@ -0,0 +1,98 @@
/*
* string1.lex: Handling strings by using input()
*/
%{
#include <ctype.h>
#include <malloc.h>
#define ALLOC_SIZE 32 /* for (re)allocating the buffer */
#define isodigit(x) ((x) >= '0' && (x) <= '7')
#define hextoint(x) (isdigit((x)) ? (x) - '0' : ((x) - 'A') + 10)
void yyerror(char *message)
{
printf("\nError: %s\n",message);
}
%}
%%
\" {
int inch,count,max_size;
char *buffer;
int temp;
buffer = malloc(ALLOC_SIZE);
max_size = ALLOC_SIZE;
inch = input();
count = 0;
while(inch != EOF && inch != '"' && inch != '\n'){
if(inch == '\\'){
inch = input();
switch(inch){
case '\n': inch = input(); break;
case 'b' : inch = '\b'; break;
case 't' : inch = '\t'; break;
case 'n' : inch = '\n'; break;
case 'v' : inch = '\v'; break;
case 'f' : inch = '\f'; break;
case 'r' : inch = '\r'; break;
case 'X' :
case 'x' : inch = input();
if(isxdigit(inch)){
temp = hextoint(toupper(inch));
inch = input();
if(isxdigit(inch)){
temp = (temp << 4) + hextoint(toupper(inch));
} else {
unput(inch);
}
inch = temp;
} else {
unput(inch);
inch = 'x';
}
break;
default:
if(isodigit(inch)){
temp = inch - '0';
inch = input();
if(isodigit(inch)){
temp = (temp << 3) + (inch - '0');
} else {
unput(inch);
goto done;
}
inch = input();
if(isodigit(inch)){
temp = (temp << 3) + (inch - '0');
} else {
unput(inch);
}
done:
inch = temp;
}
}
}
buffer[count++] = inch;
if(count >= max_size){
buffer = realloc(buffer,max_size + ALLOC_SIZE);
max_size += ALLOC_SIZE;
}
inch = input();
}
if(inch == EOF || inch == '\n'){
yyerror("Unterminated string.");
}
buffer[count] = '\0';
printf("String = \"%s\"\n",buffer);
free(buffer);
}
.
\n
%%
@@ -0,0 +1,94 @@
/*
* string2.lex: An example of using scanning strings
* by using start states.
*/
%{
#include <ctype.h>
#include <malloc.h>
#define isodigit(x) ((x) >= '0' && (x) <= '7')
#define hextoint(x) (isdigit((x)) ? (x) - '0' : ((x) - 'A') + 10)
char *buffer = NULL;
int buffer_size = 0;
void yyerror(char *message)
{
printf("\nError: %s\n",message);
}
%}
%x STRING
hex (x|X)[0-9a-fA-F]{1,2}
oct [0-7]{1,3}
%%
\" {
buffer = malloc(1);
buffer_size = 1; strcpy(buffer,"");
BEGIN(STRING);
}
<STRING>\n {
yyerror("Unterminated string");
free(buffer);
BEGIN(INITIAL);
}
<STRING><<EOF>> {
yyerror("EOF in string");
free(buffer);
BEGIN(INITIAL);
}
<STRING>[^\\\n"] {
buffer = realloc(buffer,buffer_size+yyleng+1);
buffer_size += yyleng;
strcat(buffer,yytext);
}
<STRING>\\\n /* ignore this */
<STRING>\\{hex} {
int temp =0,loop = 0;
for(loop=yyleng-2; loop>0; loop--){
temp <<= 4;
temp += hextoint(toupper(yytext[yyleng-loop]));
}
buffer = realloc(buffer,buffer_size+1);
buffer[buffer_size-1] = temp;
buffer[buffer_size] = '\0';
buffer_size += 1;
}
<STRING>\\{oct} {
int temp =0,loop = 0;
for(loop=yyleng-1; loop>0; loop--){
temp <<= 3;
temp += (yytext[yyleng-loop] - '0');
}
buffer = realloc(buffer,buffer_size+1);
buffer[buffer_size-1] = temp;
buffer[buffer_size] = '\0';
buffer_size += 1;
}
<STRING>\\[^\n] {
buffer = realloc(buffer,buffer_size+1);
switch(yytext[yyleng-1]){
case 'b' : buffer[buffer_size-1] = '\b'; break;
case 't' : buffer[buffer_size-1] = '\t'; break;
case 'n' : buffer[buffer_size-1] = '\n'; break;
case 'v' : buffer[buffer_size-1] = '\v'; break;
case 'f' : buffer[buffer_size-1] = '\f'; break;
case 'r' : buffer[buffer_size-1] = '\r'; break;
default : buffer[buffer_size-1] = yytext[yyleng-1];
}
buffer[buffer_size] = '\0';
buffer_size += 1;
}
<STRING>\" {
printf("string = \"%s\"",buffer);
free(buffer);
BEGIN(INITIAL);
}
%%
@@ -0,0 +1,21 @@
"This is a string"
"The next string will be empty"
""
"This is a string with a \b(\\b) in it"
"This is a string with a \t(\\t) in it"
"This is a string with a \n(\\n) in it"
"This is a string with a \v(\\v) in it"
"This is a string with a \f(\\f) in it"
"This is a string with a \r(\\r) in it"
"This is a string with a \"(\\\") in it"
"This is a string with a \z(\\z) in it"
"This is a string with a \X4a(\\X4a) in it"
"This is a string with a \x4a(\\x4a) in it"
"This is a string with a \x7(\\x7) in it"
"This is a string with a \112(\\112) in it"
"This is a string with a \043(\\043) in it"
"This is a string with a \7(\\7) in it"
"This is a multi-line \
string"
"This is an unterminated string
"This is an unterminated string too
@@ -0,0 +1,32 @@
/*
* unput.l : An example of what *not*
* to do with unput().
*/
%{
#include <stdio.h>
void putback_yytext(void);
%}
%%
foobar putback_yytext();
raboof putback_yytext();
%%
void putback_yytext(void)
{
int i;
int l = strlen(yytext);
char buffer[YY_BUF_SIZE];
strcpy(buffer,yytext);
printf("Got: %s\n",yytext);
for(i=0; i<l; i++){
unput(buffer[i]);
}
}
@@ -0,0 +1,31 @@
%{
#include <ctype.h>
void user_action(void);
#define YY_USER_ACTION user_action();
%}
%%
.* ECHO;
\n ECHO;
%%
void user_action(void)
{
int loop;
for(loop=0; loop<yyleng; loop++){
if(islower(yytext[loop])){
yytext[loop] = toupper(yytext[loop]);
}
}
}
@@ -0,0 +1,30 @@
%{
#define YY_USER_INIT open_input_file()
extern FILE *yyin;
void open_input_file(void)
{
char *file_name,buffer[1024];
yyin = NULL;
while(yyin == NULL){
printf("Input file: ");
file_name = fgets(buffer,1024,stdin);
if(file_name){
file_name[strlen(file_name)-1] = '\0';
yyin = fopen(file_name,"r");
if(yyin == NULL){
printf("Unable to open \"%s\"\n",file_name);
}
} else {
printf("stdin\n");
yyin = stdin;
break;
}
}
}
%}
%%
@@ -0,0 +1,122 @@
%{
/*
* wc.lex : A simple example of using FLEX
* to create a wc-like utility.
*
* See MISC/fastwc/ in the flex distribution for examples
* of how to write this scanner for maximum performance.
*/
int numchars = 0;
int numwords = 0;
int numlines = 0;
int totchars = 0;
int totwords = 0;
int totlines = 0;
/*
* rules start from here
*/
%}
%%
[\n] { numchars++; numlines++; }
[\r] { numchars++; }
[^ \t\n]+ { numwords++; numchars += yyleng; }
. { numchars++; }
%%
/*
* additional C code start from here. This supplies
* all the argument processing etc.
*/
int main(int argc, char *argv[])
{
int loop,first=1;
int lflag = 0; /* 1 if we count # of lines */
int wflag = 0; /* 1 if we count # of words */
int cflag = 0; /* 1 if we count # of characters */
int fflag = 0; /* 1 if we have a file name */
for(loop=1; loop<argc; loop++){
if(argv[loop][0] == '-'){
switch(argv[loop][1]){
case 'l':
lflag = 1;
break;
case 'w':
wflag = 1;
break;
case 'c':
cflag = 1;
break;
default:
fprintf(stderr,"unknown option -%c\n",
argv[loop][1]);
}
}
}
if(lflag == 0 && wflag == 0 && cflag == 0){
lflag = wflag = cflag = 1; /* default to all on */
}
for(loop=1; loop<argc; loop++){
if(argv[loop][0] != '-'){
fflag = 1;
numlines = numchars = numwords = 0;
if((yyin = fopen(argv[loop],"rb")) != NULL){
if(first){
first = 0;
} else {
YY_NEW_FILE;
}
(void) yylex();
fclose(yyin);
totwords += numwords;
totchars += numchars;
totlines += numlines;
printf("file : %25s :",argv[loop]) ;
if(lflag){
fprintf(stdout,"lines %5d ",numlines);
}
if(cflag){
fprintf(stdout,"characters %5d ",numchars);
}
if(wflag){
fprintf(stdout,"words %5d ",numwords);
}
fprintf(stdout,"\n");
}else{
fprintf(stderr,"wc : file not found %s\n",argv[loop]);
}
}
}
if(!fflag){
fprintf(stderr,"usage : wc [-l -w -c] file [file...]\n");
fprintf(stderr,"-l = count lines\n");
fprintf(stderr,"-c = count characters\n");
fprintf(stderr,"-w = count words\n");
exit(1);
}
for(loop=0;loop<79; loop++){
fprintf(stdout,"-");
}
fprintf(stdout,"\n");
fprintf(stdout,"total : %25s ","") ;
if(lflag){
fprintf(stdout,"lines %5d ",totlines);
}
if(cflag){
fprintf(stdout,"characters %5d ",totchars);
}
if(wflag){
fprintf(stdout,"words %5d ",totwords);
}
fprintf(stdout,"\n");
return(0);
}
@@ -0,0 +1,29 @@
/*
* yymore.lex: An example of using yymore()
* to good effect.
*/
%{
#include <memory.h>
void yyerror(char *message)
{
printf("Error: %s\n",message);
}
%}
%x STRING
%%
\" BEGIN(STRING);
<STRING>[^\\\n"]* yymore();
<STRING><<EOF>> yyerror("EOF in string."); BEGIN(INITIAL);
<STRING>\n yyerror("Unterminated string."); BEGIN(INITIAL);
<STRING>\\\n yymore();
<STRING>\" {
yytext[yyleng-1] = '\0';
printf("string = \"%s\"",yytext); BEGIN(INITIAL);
}
%%
@@ -0,0 +1,33 @@
/*
* yymore.lex: An example of using yymore()
* to good effect.
*/
%{
#include <memory.h>
void yyerror(char *message)
{
printf("Error: %s\n",message);
}
%}
%x STRING
%%
\" BEGIN(STRING);
<STRING>[^\\\n"]* yymore();
<STRING><<EOF>> yyerror("EOF in string."); BEGIN(INITIAL);
<STRING>\n yyerror("Unterminated string."); BEGIN(INITIAL);
<STRING>\\\n {
bcopy(yytext,yytext+2,yyleng-2);
yytext += 2; yyleng -= 2;
yymore();
}
<STRING>\" {
yyleng -= 1; yytext[yyleng] = '\0';
printf("string = \"%s\"",yytext); BEGIN(INITIAL);
}
%%
@@ -0,0 +1,7 @@
"This is a test \
of multi-line string \
scanning in flex. \
This may be breaking some law \
of usage though..."
@@ -0,0 +1,58 @@
// An example of using the flex C++ scanner class.
%option C++ noyywrap
%{
int mylineno = 0;
%}
string \"[^\n"]+\"
ws [ \t]+
alpha [A-Za-z]
dig [0-9]
name ({alpha}|{dig}|\$)({alpha}|{dig}|\_|\.|\-|\/|\$)*
num1 [-+]?{dig}+\.?([eE][-+]?{dig}+)?
num2 [-+]?{dig}*\.{dig}+([eE][-+]?{dig}+)?
number {num1}|{num2}
%%
{ws} /* skip blanks and tabs */
"/*" {
int c;
while((c = yyinput()) != 0)
{
if(c == '\n')
++mylineno;
else if(c == '*')
{
if((c = yyinput()) == '/')
break;
else
unput(c);
}
}
}
{number} std::cout << "number " << YYText() << '\n';
\n mylineno++;
{name} std::cout << "name " << YYText() << '\n';
{string} std::cout << "string " << YYText() << '\n';
%%
int main( int /* argc */, char** /* argv */ )
{
FlexLexer* lexer = new yyFlexLexer;
while(lexer->yylex() != 0)
;
return 0;
}