diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..bec43f06 --- /dev/null +++ b/.gitignore @@ -0,0 +1,299 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.dll +*.o +*.a +*.exe +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Typescript v1 declaration files +typings/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs diff --git a/Makefile b/Makefile index 437261b9..c78cdbb9 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ LIBNAME=libpeg-markdown PROGRAM=markdown$(X) CFLAGS ?= -Wall -O3 -ansi -D_GNU_SOURCE # -flto for newer GCC versions OBJS=markdown_parser.o markdown_output.o markdown_lib.o utility_functions.o parsing_functions.o odf.o -PEGDIR=peg-0.1.9 +PEGDIR=peg-0.1.18 LEG=$(PEGDIR)/leg$(X) PKG_CONFIG = pkg-config diff --git a/README.markdown b/README.markdown index 47e2c4b8..227d799d 100644 --- a/README.markdown +++ b/README.markdown @@ -118,6 +118,16 @@ peg-markdown source, execute: cd peg-0.1.4 make PKG_CONFIG=c:/path/to/glib/bin/pkg-config.exe +Compiling as a .DLL with Visual Studio on Windows +------------------------------------------------- + +This may require some extra work if you're not using Visual Studio 2017. + +- Open win/peg-markdown.sln. +- Right click on the solution in Visual Studio Solution Explorer and perform a nuget package restore. +- Move glibconfig.h from packages\glib\build\native\include\glib to glib\build\native\include. +- Build in x86 or x64. + Extensions ========== diff --git a/export.h b/export.h new file mode 100644 index 00000000..1cae6eda --- /dev/null +++ b/export.h @@ -0,0 +1,10 @@ +#ifndef EXPORT_H +#define EXPORT_H + +#ifdef _MSC_VER +#define EXPORT __declspec(dllexport) +#else +#define EXPORT +#endif + +#endif // EXPORT_H diff --git a/markdown_lib.h b/markdown_lib.h index c923e1a7..b02da362 100644 --- a/markdown_lib.h +++ b/markdown_lib.h @@ -5,6 +5,9 @@ #include #include +// EXPORT macro for MSVC +#include "export.h" + #ifdef __cplusplus extern "C" { #endif @@ -21,11 +24,12 @@ enum markdown_formats { HTML_FORMAT, LATEX_FORMAT, GROFF_MM_FORMAT, - ODF_FORMAT + ODF_FORMAT, + WPF_XAML_FORMAT }; -GString * markdown_to_g_string(char *text, int extensions, int output_format); -char * markdown_to_string(char *text, int extensions, int output_format); +EXPORT GString * markdown_to_g_string(char *text, int extensions, int output_format); +EXPORT char * markdown_to_string(char *text, int extensions, int output_format); #ifdef __cplusplus } diff --git a/peg-0.1.18/ChangeLog b/peg-0.1.18/ChangeLog new file mode 100644 index 00000000..1fde6880 --- /dev/null +++ b/peg-0.1.18/ChangeLog @@ -0,0 +1,118 @@ +2016-07-22 Ian Piumarta + + * src/version.h (PEG_LEVEL): Version 0.1.18. + * src/tree.h: Rule_compile_c takes nolines argument for option -P. + * src/compile.c, src/peg.c, src/leg.leg (main): Add option -P. + Generate #line directives for all actions. + * src/peg.1: Document option -P. + +2016-07-14 Ian Piumarta + + * src/version.h: 0.1.17 + + * src/leg.leg: Remember line numbers for headers and trailer. + Emit #line directives in the generated file. + +2016-06-25 piumarta + + * src/version.h: 0.1.16 + + * src/tree.[ch], src/compile.c, src/leg.leg: Add @-actions. + + * src/peg.1: Explain @-actions. + + * src/peg/peg-c, src/leg.c: Regenerate C source. + +2013-12-18 piumarta + + * src/version.h: 0.1.15 + + * src/compile.c: YY_FREE takes context and pointer as arguments. + + * YYRELEASE: Pass yyctx and pointer to YY_FREE. + +2013-12-01 Ian Piumarta + + * src/version.h: 0.1.14 + + * src/peg.1: Fix several typos and escape backslashes (thanks to + Giulio Paci). + + * LICENSE.txt: Replace "the the" with "the". + +2013-08-16 Ian Piumarta + + * src/compile.c: Predicate actions can refer to yytext (thanks to + Gregory Pakosz). + + * src/leg.leg: Hexadecimal character escapes are supported by leg + (thanks to Hugo Etchegoyen). + +2013-07-20 Ian Piumarta + + * src/getopt.c: Use BSD-licensed getopt() in Windows + build. + + * src/compile.c: Verbose mode handles Variable nodes. + +2013-06-03 Ian Piumarta + + * src/leg.leg, src/compile.c: Add error actions via "~" operator. + + * src/compile.c: Support declaration of local variables at the top + level of semantic actions. Dynamically grow data structures to + remove artificial limits on rule recursion (thanks to Alex + Klinkhamer). Many small changes to better support C++. + + * src/peg.1: Update manual page to describe new features. + + Add build files for Win32 and MacOS thanks to Fyodor Sheremetyev). + +2012-04-29 Ian Piumarta + + * compile.c: Move global state into a structure to facilitate + reentrant and thread-safe parsers (thanks to Dmitry Lipovoi). + +2012-03-29 Ian Piumarta + + * leg.leg: Allow nested, matched braces within actions. + +2011-11-25 Ian Piumarta + + * compile.c: Fix matching of 8-bit chars to allow utf-8 sequences + in matching expressions (thanks to Gregory Pakosz). + +2011-11-24 Ian Piumarta + + * compile.c: Allow octal escapes in character classes. + +2011-11-24 Ian Piumarta + + * Makefile: Remove dwarf sym dirs when cleaning. + + * compile.c: Fix size calculation when resizing text + buffers. + + * leg.leg, peg.peg: Backslash can be escaped. + +2009-08-26 Ian Piumarta + + * leg.leg: Fix match of a single single quote character. + + * examples/basic.leg: Rename getline -> nextline to avoid C + namespace conflict. + +2007-09-13 Ian Piumarta + + * leg.leg: Allow matched braces inside leg actions. Handle empty + rules. Handle empty grammars. + +2007-08-31 Ian Piumarta + + * compile.c: Grow buffers while (not if) they are too + small. Remove dependencies on grammar files. Add more basic + examples. + +2007-05-15 Ian Piumarta + + First public release. diff --git a/peg-0.1.18/LICENSE.txt b/peg-0.1.18/LICENSE.txt new file mode 100644 index 00000000..7eee1eaf --- /dev/null +++ b/peg-0.1.18/LICENSE.txt @@ -0,0 +1,14 @@ +Copyright (c) 2007-2013, Ian Piumarta +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the 'Software'), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, and/or sell copies of the +Software, and to permit persons to whom the Software is furnished to do so, +provided that the above copyright notice(s) and this permission notice appear +in all copies or substantial portions of the Software. Inclusion of the +above copyright notice(s) and this permission notice in supporting +documentation would be appreciated but is not required. + +THE SOFTWARE IS PROVIDED 'AS IS'. USE ENTIRELY AT YOUR OWN RISK. diff --git a/peg-0.1.18/Makefile b/peg-0.1.18/Makefile new file mode 100644 index 00000000..6a46e57f --- /dev/null +++ b/peg-0.1.18/Makefile @@ -0,0 +1,87 @@ +CFLAGS = -g -Wall $(OFLAGS) $(XFLAGS) -Isrc +OFLAGS = -O3 -DNDEBUG +#OFLAGS = -pg + +OBJS = tree.o compile.o + +all : peg leg + +peg : peg.o $(OBJS) + $(CC) $(CFLAGS) -o $@-new peg.o $(OBJS) + mv $@-new $@ + +leg : leg.o $(OBJS) + $(CC) $(CFLAGS) -o $@-new leg.o $(OBJS) + mv $@-new $@ + +ROOT = +PREFIX = /usr/local +BINDIR = $(ROOT)$(PREFIX)/bin +MANDIR = $(ROOT)$(PREFIX)/man/man1 + +install : $(BINDIR) $(BINDIR)/peg $(BINDIR)/leg $(MANDIR) $(MANDIR)/peg.1 + +$(BINDIR) : + mkdir -p $(BINDIR) + +$(BINDIR)/% : % + cp -p $< $@ + strip $@ + +$(MANDIR) : + mkdir -p $(MANDIR) + +$(MANDIR)/% : src/% + cp -p $< $@ + +uninstall : .FORCE + rm -f $(BINDIR)/peg + rm -f $(BINDIR)/leg + rm -f $(MANDIR)/peg.1 + +%.o : src/%.c + $(CC) $(CFLAGS) -c -o $@ $< + +peg.o : src/peg.c src/peg.peg-c + +leg.o : src/leg.c + +check : check-peg check-leg + +check-peg : peg.peg-c .FORCE + diff src/peg.peg-c peg.peg-c + +check-leg : leg.c .FORCE + diff src/leg.c leg.c + +peg.peg-c : src/peg.peg peg + ./peg -o $@ $< + +leg.c : src/leg.leg leg + ./leg -o $@ $< + +new : newpeg newleg + +newpeg : peg.peg-c + mv src/peg.peg-c src/peg.peg-c- + mv peg.peg-c src/. + +newleg : leg.c + mv src/leg.c src/leg.c- + mv leg.c src/. + +test examples : peg leg .FORCE + $(SHELL) -ec '(cd examples; $(MAKE))' + +clean : .FORCE + rm -f src/*~ *~ *.o *.peg.[cd] *.leg.[cd] peg.peg-c leg.c + $(SHELL) -ec '(cd examples; $(MAKE) $@)' + +spotless : clean .FORCE + rm -f src/*- + rm -rf build + rm -f peg + rm -f leg + $(SHELL) -ec '(cd examples; $(MAKE) $@)' + +.FORCE : diff --git a/peg-0.1.18/README.txt b/peg-0.1.18/README.txt new file mode 100644 index 00000000..1b011d00 --- /dev/null +++ b/peg-0.1.18/README.txt @@ -0,0 +1,42 @@ +Building on a Unix-like system +------------------------------ + +Type 'make' or 'make test'. + +The latter builds all the examples and runs them, comparing their +output with the expected output. + +Type 'make install' to install the binaries and manual page under +/usr/local. (Type 'make uninstall' to remove them.) You may have to +do this using 'sudo' or while logged in as root. + +Edit 'Makefile' to change the way things are built and/or the places +where things are installed. + + +Building on MacOS X +------------------- + +Run the 'build-mac.sh' script from a terminal or by double-clicking on +it in the Finder. + +You will need Xcode. The provided project is known to work with Xcode +versions 3.2.6 and 4.3.2. + +Modify build-mac.sh and/or peg.xcodeproj to change the way things are +built. + + +Building on Windows +------------------- + +Run the 'build-win.cmd' script. + +You will need Visual Studio 2010 Express. + +Modify build-win.cmd, leg.vcxproj, leg.vcxproj.filters, peg.gyp, +peg.sln, peg.vcxproj and/or peg.vcxproj.filters to change the way +things are built. + +Local implementations of getopt() and basename() are provided in the +'win' directory. diff --git a/peg-0.1.18/build-mac.sh b/peg-0.1.18/build-mac.sh new file mode 100644 index 00000000..b8180a4f --- /dev/null +++ b/peg-0.1.18/build-mac.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +xcodebuild -project peg.xcodeproj -configuration Release + +cp build/Release/peg ./ +cp build/Release/leg ./ diff --git a/peg-0.1.18/build-win.cmd b/peg-0.1.18/build-win.cmd new file mode 100644 index 00000000..0651e7d3 --- /dev/null +++ b/peg-0.1.18/build-win.cmd @@ -0,0 +1,5 @@ +@echo off +call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\vcvars32.bat" +msbuild peg.sln /p:Configuration=Release + +xcopy /Y /D Release\*.exe .\ diff --git a/peg-0.1.9/examples/Makefile b/peg-0.1.18/examples/Makefile similarity index 77% rename from peg-0.1.9/examples/Makefile rename to peg-0.1.18/examples/Makefile index 30d3cc8f..f943a4d1 100644 --- a/peg-0.1.9/examples/Makefile +++ b/peg-0.1.18/examples/Makefile @@ -1,4 +1,4 @@ -EXAMPLES = test rule accept wc dc dcv calc basic localctx +EXAMPLES = test rule accept wc dc dcv calc basic localpeg localleg erract CFLAGS = -g -O3 @@ -71,14 +71,30 @@ basic : .FORCE rm -f $@.out @echo -localctx : .FORCE +localpeg : .FORCE ../peg -o test.peg.c test.peg - $(CC) $(CFLAGS) -o localctx localctx.c + $(CC) $(CFLAGS) -o localpeg localpeg.c echo 'ab.ac.ad.ae.afg.afh.afg.afh.afi.afj.' | ./$@ | $(TEE) $@.out $(DIFF) $@.ref $@.out rm -f $@.out @echo +localleg : .FORCE + ../leg -o localleg.leg.c localleg.leg + $(CC) $(CFLAGS) -o localleg localleg.leg.c + ./$@ < localleg.leg | $(TEE) $@.out + $(DIFF) $@.ref $@.out + rm -f $@.out + @echo + +erract : .FORCE + ../leg -o erract.leg.c erract.leg + $(CC) $(CFLAGS) -o erract erract.leg.c + echo '6*9' | ./$@ | $(TEE) $@.out + $(DIFF) $@.ref $@.out + rm -f $@.out + @echo + clean : .FORCE rm -f *~ *.o *.[pl]eg.[cd] $(EXAMPLES) rm -rf *.dSYM diff --git a/peg-0.1.9/examples/accept.c b/peg-0.1.18/examples/accept.c similarity index 100% rename from peg-0.1.9/examples/accept.c rename to peg-0.1.18/examples/accept.c diff --git a/peg-0.1.9/examples/accept.peg b/peg-0.1.18/examples/accept.peg similarity index 100% rename from peg-0.1.9/examples/accept.peg rename to peg-0.1.18/examples/accept.peg diff --git a/peg-0.1.9/examples/accept.ref b/peg-0.1.18/examples/accept.ref similarity index 100% rename from peg-0.1.9/examples/accept.ref rename to peg-0.1.18/examples/accept.ref diff --git a/peg-0.1.9/examples/basic.leg b/peg-0.1.18/examples/basic.leg similarity index 100% rename from peg-0.1.9/examples/basic.leg rename to peg-0.1.18/examples/basic.leg diff --git a/peg-0.1.9/examples/basic.ref b/peg-0.1.18/examples/basic.ref similarity index 100% rename from peg-0.1.9/examples/basic.ref rename to peg-0.1.18/examples/basic.ref diff --git a/peg-0.1.9/examples/bench.bas b/peg-0.1.18/examples/bench.bas similarity index 100% rename from peg-0.1.9/examples/bench.bas rename to peg-0.1.18/examples/bench.bas diff --git a/peg-0.1.9/examples/calc.leg b/peg-0.1.18/examples/calc.leg similarity index 100% rename from peg-0.1.9/examples/calc.leg rename to peg-0.1.18/examples/calc.leg diff --git a/peg-0.1.9/examples/calc.ref b/peg-0.1.18/examples/calc.ref similarity index 100% rename from peg-0.1.9/examples/calc.ref rename to peg-0.1.18/examples/calc.ref diff --git a/peg-0.1.9/examples/dc.c b/peg-0.1.18/examples/dc.c similarity index 100% rename from peg-0.1.9/examples/dc.c rename to peg-0.1.18/examples/dc.c diff --git a/peg-0.1.9/examples/dc.peg b/peg-0.1.18/examples/dc.peg similarity index 100% rename from peg-0.1.9/examples/dc.peg rename to peg-0.1.18/examples/dc.peg diff --git a/peg-0.1.9/examples/dc.ref b/peg-0.1.18/examples/dc.ref similarity index 100% rename from peg-0.1.9/examples/dc.ref rename to peg-0.1.18/examples/dc.ref diff --git a/peg-0.1.9/examples/dcv.c b/peg-0.1.18/examples/dcv.c similarity index 100% rename from peg-0.1.9/examples/dcv.c rename to peg-0.1.18/examples/dcv.c diff --git a/peg-0.1.9/examples/dcv.peg b/peg-0.1.18/examples/dcv.peg similarity index 100% rename from peg-0.1.9/examples/dcv.peg rename to peg-0.1.18/examples/dcv.peg diff --git a/peg-0.1.9/examples/dcv.ref b/peg-0.1.18/examples/dcv.ref similarity index 100% rename from peg-0.1.9/examples/dcv.ref rename to peg-0.1.18/examples/dcv.ref diff --git a/peg-0.1.18/examples/erract.leg b/peg-0.1.18/examples/erract.leg new file mode 100644 index 00000000..55757302 --- /dev/null +++ b/peg-0.1.18/examples/erract.leg @@ -0,0 +1,27 @@ +%{ +#include +%} + +Expr = a:NUMBER PLUS ~{ printf("fail at PLUS\n") } b:NUMBER { printf("got addition\n"); } + | ( a:NUMBER MINUS b:NUMBER { printf("got subtraction\n"); } ) ~{ printf("fail at subtraction\n") } + | a:NUMBER TIMES b:NUMBER { printf("got multiplication\n"); } + | a:NUMBER DIVIDE b:NUMBER { printf("got division\n"); } + +NUMBER = < [0-9]+ > - { $$= atoi(yytext); } +PLUS = '+' - +MINUS = '-' - +TIMES = '*' - +DIVIDE = '/' - + +- = (SPACE | EOL)* +SPACE = [ \t] +EOL = '\n' | '\r\n' | '\r' | ';' + +%% + +int main() +{ + while (yyparse()); + + return 0; +} diff --git a/peg-0.1.18/examples/erract.ref b/peg-0.1.18/examples/erract.ref new file mode 100644 index 00000000..338ffcfa --- /dev/null +++ b/peg-0.1.18/examples/erract.ref @@ -0,0 +1,4 @@ +fail at PLUS +fail at subtraction +got multiplication +fail at subtraction diff --git a/peg-0.1.9/examples/fibonacci.bas b/peg-0.1.18/examples/fibonacci.bas similarity index 100% rename from peg-0.1.9/examples/fibonacci.bas rename to peg-0.1.18/examples/fibonacci.bas diff --git a/peg-0.1.9/examples/left.c b/peg-0.1.18/examples/left.c similarity index 100% rename from peg-0.1.9/examples/left.c rename to peg-0.1.18/examples/left.c diff --git a/peg-0.1.9/examples/left.peg b/peg-0.1.18/examples/left.peg similarity index 100% rename from peg-0.1.9/examples/left.peg rename to peg-0.1.18/examples/left.peg diff --git a/peg-0.1.18/examples/localleg.leg b/peg-0.1.18/examples/localleg.leg new file mode 100644 index 00000000..4d52d569 --- /dev/null +++ b/peg-0.1.18/examples/localleg.leg @@ -0,0 +1,24 @@ +%{ +#define YY_CTX_LOCAL 1 +#define YY_CTX_MEMBERS \ + int count; +%} + +Char = ('\n' | '\r\n' | '\r') { yy->count++ } + | . + +%% + +#include +#include + +int main() +{ + yycontext yy; + memset(&yy, 0, sizeof(yy)); + while (yyparse(&yy)) + ; + printf("%d newlines\n", yy.count); + yyrelease(&yy); + return 0; +} diff --git a/peg-0.1.18/examples/localleg.ref b/peg-0.1.18/examples/localleg.ref new file mode 100644 index 00000000..f4a09198 --- /dev/null +++ b/peg-0.1.18/examples/localleg.ref @@ -0,0 +1 @@ +24 newlines diff --git a/peg-0.1.9/examples/localctx.c b/peg-0.1.18/examples/localpeg.c similarity index 100% rename from peg-0.1.9/examples/localctx.c rename to peg-0.1.18/examples/localpeg.c diff --git a/peg-0.1.9/examples/localctx.ref b/peg-0.1.18/examples/localpeg.ref similarity index 100% rename from peg-0.1.9/examples/localctx.ref rename to peg-0.1.18/examples/localpeg.ref diff --git a/peg-0.1.9/examples/rule.c b/peg-0.1.18/examples/rule.c similarity index 100% rename from peg-0.1.9/examples/rule.c rename to peg-0.1.18/examples/rule.c diff --git a/peg-0.1.9/examples/rule.peg b/peg-0.1.18/examples/rule.peg similarity index 100% rename from peg-0.1.9/examples/rule.peg rename to peg-0.1.18/examples/rule.peg diff --git a/peg-0.1.9/examples/rule.ref b/peg-0.1.18/examples/rule.ref similarity index 100% rename from peg-0.1.9/examples/rule.ref rename to peg-0.1.18/examples/rule.ref diff --git a/peg-0.1.9/examples/test.bas b/peg-0.1.18/examples/test.bas similarity index 100% rename from peg-0.1.9/examples/test.bas rename to peg-0.1.18/examples/test.bas diff --git a/peg-0.1.9/examples/test.c b/peg-0.1.18/examples/test.c similarity index 100% rename from peg-0.1.9/examples/test.c rename to peg-0.1.18/examples/test.c diff --git a/peg-0.1.9/examples/test.peg b/peg-0.1.18/examples/test.peg similarity index 100% rename from peg-0.1.9/examples/test.peg rename to peg-0.1.18/examples/test.peg diff --git a/peg-0.1.9/examples/test.ref b/peg-0.1.18/examples/test.ref similarity index 100% rename from peg-0.1.9/examples/test.ref rename to peg-0.1.18/examples/test.ref diff --git a/peg-0.1.9/examples/username.leg b/peg-0.1.18/examples/username.leg similarity index 100% rename from peg-0.1.9/examples/username.leg rename to peg-0.1.18/examples/username.leg diff --git a/peg-0.1.9/examples/wc.leg b/peg-0.1.18/examples/wc.leg similarity index 100% rename from peg-0.1.9/examples/wc.leg rename to peg-0.1.18/examples/wc.leg diff --git a/peg-0.1.9/examples/wc.ref b/peg-0.1.18/examples/wc.ref similarity index 100% rename from peg-0.1.9/examples/wc.ref rename to peg-0.1.18/examples/wc.ref diff --git a/peg-0.1.18/leg.exe b/peg-0.1.18/leg.exe new file mode 100644 index 00000000..90af1451 Binary files /dev/null and b/peg-0.1.18/leg.exe differ diff --git a/peg-0.1.18/leg.vcxproj b/peg-0.1.18/leg.vcxproj new file mode 100644 index 00000000..d8f5cb4e --- /dev/null +++ b/peg-0.1.18/leg.vcxproj @@ -0,0 +1,146 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {5ECEC9E5-8F23-47B6-93E0-C3B328B3BE66} + Win32Proj + leg + $(ProjectName) + + + + Application + + + v141 + + + v141 + + + v141 + + + v141 + + + + + + + + + $(ExecutablePath);$(MSBuildProjectDirectory)\.\bin\;$(MSBuildProjectDirectory)\.\bin\ + $(Configuration)\obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)\ + + + + win;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;DEBUG;%(PreprocessorDefinitions) + + + true + $(OutDir)$(ProjectName).exe + Console + + + win;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;DEBUG;%(PreprocessorDefinitions);%(PreprocessorDefinitions) + + + "$(OutputPath)leg.exe" "$(OutputPath)markdown_parser.leg" > "$(SolutionDir)..\markdown_parser.c" + + + + + win;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;DEBUG;%(PreprocessorDefinitions) + + + true + $(OutDir)$(ProjectName).exe + Console + + + win;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;DEBUG;%(PreprocessorDefinitions);%(PreprocessorDefinitions) + + + "$(OutputPath)leg.exe" "$(OutputPath)markdown_parser.leg" > "$(SolutionDir)..\markdown_parser.c" + + + + + + + + + + + + + + win;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + + + true + $(OutDir)$(ProjectName).exe + Console + + + win;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions);%(PreprocessorDefinitions) + + + "$(OutputPath)leg.exe" "$(OutputPath)markdown_parser.leg" > "$(SolutionDir)..\markdown_parser.c" + + + + + win;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + + + true + $(OutDir)$(ProjectName).exe + Console + + + win;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions);%(PreprocessorDefinitions) + + + "$(OutputPath)leg.exe" "$(OutputPath)markdown_parser.leg" > "$(SolutionDir)..\markdown_parser.c" + + + + + + + + + + + + + + \ No newline at end of file diff --git a/peg-0.1.18/leg.vcxproj.filters b/peg-0.1.18/leg.vcxproj.filters new file mode 100644 index 00000000..c371b0d7 --- /dev/null +++ b/peg-0.1.18/leg.vcxproj.filters @@ -0,0 +1,19 @@ + + + + + {47FC5EC4-15EB-E92F-89D7-AFE51CF838A9} + + + + + + win + + + + + + + + \ No newline at end of file diff --git a/peg-0.1.18/peg.exe b/peg-0.1.18/peg.exe new file mode 100644 index 00000000..7c7408d9 Binary files /dev/null and b/peg-0.1.18/peg.exe differ diff --git a/peg-0.1.18/peg.gyp b/peg-0.1.18/peg.gyp new file mode 100644 index 00000000..17c5bc02 --- /dev/null +++ b/peg-0.1.18/peg.gyp @@ -0,0 +1,81 @@ +{ + 'targets': [ + { + 'target_name': 'peg', + 'type': 'executable', + 'msvs_guid': '5ECEC9E5-8F23-47B6-93E0-C3B328B3BE65', + 'sources': [ + 'peg.c', + 'tree.c', + 'compile.c', + ], + 'conditions': [ + ['OS=="win"', { + 'include_dirs': [ + 'win', + ], + 'sources': [ + 'win/getopt.c', + ], + }], + ], + }, + { + 'target_name': 'leg', + 'type': 'executable', + 'msvs_guid': '5ECEC9E5-8F23-47B6-93E0-C3B328B3BE66', + 'sources': [ + 'leg.c', + 'tree.c', + 'compile.c', + ], + 'conditions': [ + ['OS=="win"', { + 'include_dirs': [ + 'win', + ], + 'sources': [ + 'win/getopt.c', + ], + }], + ], + }, + ], + + 'target_defaults': { + 'configurations': { + 'Debug': { + 'defines': [ + 'DEBUG', + ], + }, + 'Release': { + 'defines': [ + 'NDEBUG', + ], + }, + }, + }, + + # define default project settings + 'conditions': [ + ['OS=="win"', { + 'target_defaults': { + 'defines': [ + 'WIN32', + '_WINDOWS', + ], + 'msvs_settings': { + 'VCLinkerTool': { + 'GenerateDebugInformation': 'true', + # SubSystem values: + # 0 == not set + # 1 == /SUBSYSTEM:CONSOLE + # 2 == /SUBSYSTEM:WINDOWS + 'SubSystem': '1', + }, + }, + }, + }], + ], +} diff --git a/peg-0.1.18/peg.sln b/peg-0.1.18/peg.sln new file mode 100644 index 00000000..4956e5f4 --- /dev/null +++ b/peg-0.1.18/peg.sln @@ -0,0 +1,27 @@ +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "leg", "leg.vcxproj", "{5ECEC9E5-8F23-47B6-93E0-C3B328B3BE66}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "peg", "peg.vcxproj", "{5ECEC9E5-8F23-47B6-93E0-C3B328B3BE65}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5ECEC9E5-8F23-47B6-93E0-C3B328B3BE65}.Debug|Win32.ActiveCfg = Debug|Win32 + {5ECEC9E5-8F23-47B6-93E0-C3B328B3BE65}.Debug|Win32.Build.0 = Debug|Win32 + {5ECEC9E5-8F23-47B6-93E0-C3B328B3BE65}.Release|Win32.ActiveCfg = Release|Win32 + {5ECEC9E5-8F23-47B6-93E0-C3B328B3BE65}.Release|Win32.Build.0 = Release|Win32 + {5ECEC9E5-8F23-47B6-93E0-C3B328B3BE66}.Debug|Win32.ActiveCfg = Debug|Win32 + {5ECEC9E5-8F23-47B6-93E0-C3B328B3BE66}.Debug|Win32.Build.0 = Debug|Win32 + {5ECEC9E5-8F23-47B6-93E0-C3B328B3BE66}.Release|Win32.ActiveCfg = Release|Win32 + {5ECEC9E5-8F23-47B6-93E0-C3B328B3BE66}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + EndGlobalSection +EndGlobal diff --git a/peg-0.1.18/peg.vcxproj b/peg-0.1.18/peg.vcxproj new file mode 100644 index 00000000..1bf669d0 --- /dev/null +++ b/peg-0.1.18/peg.vcxproj @@ -0,0 +1,125 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {5ECEC9E5-8F23-47B6-93E0-C3B328B3BE65} + Win32Proj + peg + $(ProjectName) + + + + Application + + + v141 + + + v141 + + + v141 + + + v141 + + + + + + + + + $(ExecutablePath);$(MSBuildProjectDirectory)\.\bin\;$(MSBuildProjectDirectory)\.\bin\ + $(Configuration)\obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)\ + + + + win;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;DEBUG;%(PreprocessorDefinitions) + + + true + $(OutDir)$(ProjectName).exe + Console + + + win;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;DEBUG;%(PreprocessorDefinitions);%(PreprocessorDefinitions) + + + + + win;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;DEBUG;%(PreprocessorDefinitions) + + + true + $(OutDir)$(ProjectName).exe + Console + + + win;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;DEBUG;%(PreprocessorDefinitions);%(PreprocessorDefinitions) + + + + + win;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + + + true + $(OutDir)$(ProjectName).exe + Console + + + win;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions);%(PreprocessorDefinitions) + + + + + win;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + + + true + $(OutDir)$(ProjectName).exe + Console + + + win;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions);%(PreprocessorDefinitions) + + + + + + + + + + + + + + \ No newline at end of file diff --git a/peg-0.1.18/peg.vcxproj.filters b/peg-0.1.18/peg.vcxproj.filters new file mode 100644 index 00000000..68d7dd4c --- /dev/null +++ b/peg-0.1.18/peg.vcxproj.filters @@ -0,0 +1,19 @@ + + + + + {47FC5EC4-15EB-E92F-89D7-AFE51CF838A9} + + + + + + win + + + + + + + + \ No newline at end of file diff --git a/peg-0.1.18/peg.xcodeproj/project.pbxproj b/peg-0.1.18/peg.xcodeproj/project.pbxproj new file mode 100644 index 00000000..788498ff --- /dev/null +++ b/peg-0.1.18/peg.xcodeproj/project.pbxproj @@ -0,0 +1,317 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 45; + objects = { + +/* Begin PBXAggregateTarget section */ + EFBC7368F96EACB75989C21D /* All */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 007E1122105A105C63F8A59F /* Build configuration list for PBXAggregateTarget "All" */; + buildPhases = ( + ); + dependencies = ( + B85F90055126E00C1334834C /* PBXTargetDependency */, + 3DF530CEA77A591E4DFBFF2F /* PBXTargetDependency */, + ); + name = All; + productName = All; + }; +/* End PBXAggregateTarget section */ + +/* Begin PBXBuildFile section */ + 2D4E663DE432A398FC78635B /* compile.c in Sources */ = {isa = PBXBuildFile; fileRef = D4BAF07C3AF28E51DD58E853 /* compile.c */; }; + 3FE25C706AB45972C102CBB4 /* tree.c in Sources */ = {isa = PBXBuildFile; fileRef = E503317C684EFEB3E7E03861 /* tree.c */; }; + 4D30CEABCD51397A50F65058 /* compile.c in Sources */ = {isa = PBXBuildFile; fileRef = D4BAF07C3AF28E51DD58E853 /* compile.c */; }; + 7921C7C2AD25A4A4C02470F5 /* peg.c in Sources */ = {isa = PBXBuildFile; fileRef = 27FA3C119507A9A914A66936 /* peg.c */; }; + 8B61C6AE75A1750C17350E64 /* tree.c in Sources */ = {isa = PBXBuildFile; fileRef = E503317C684EFEB3E7E03861 /* tree.c */; }; + D8C3FFD80B6642D8BB341B90 /* leg.c in Sources */ = {isa = PBXBuildFile; fileRef = 454F9F599E7B65F90C62CF9C /* leg.c */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 12CD2CA862C5C1693300D7EF /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D23EA86C97C1C940E2591A06 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 84A1E5C1231D1E337ED0FC84; + remoteInfo = leg; + }; + 22C9A5E8EF76D4B801BB24E5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D23EA86C97C1C940E2591A06 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 050EA9DBA8F5C296C3E39B8A; + remoteInfo = peg; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 27FA3C119507A9A914A66936 /* peg.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = src/peg.c; sourceTree = ""; }; + 4165F882B6F541E12DBD6A0D /* peg */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = peg; sourceTree = BUILT_PRODUCTS_DIR; }; + 454F9F599E7B65F90C62CF9C /* leg.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = src/leg.c; sourceTree = ""; }; + 5C991B5472A7498A982B7350 /* peg.gyp */ = {isa = PBXFileReference; lastKnownFileType = text; path = peg.gyp; sourceTree = ""; }; + C9B3F1D07DD720C50DE87DC5 /* leg */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = leg; sourceTree = BUILT_PRODUCTS_DIR; }; + D4BAF07C3AF28E51DD58E853 /* compile.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = src/compile.c; sourceTree = ""; }; + E503317C684EFEB3E7E03861 /* tree.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = src/tree.c; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 3DF86BD64E76AD4F8D892CF6 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97D5812F2529A3E39CE17CDE /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 3854A05A8AE7E9B329F09174 /* Build */ = { + isa = PBXGroup; + children = ( + 5C991B5472A7498A982B7350 /* peg.gyp */, + ); + name = Build; + sourceTree = ""; + }; + AB7FD4EAF4FFE1A1CE63E31B = { + isa = PBXGroup; + children = ( + E2D71C5771542F758C302162 /* Source */, + AF64E60ED33C9E5DC5DB4C21 /* Products */, + 3854A05A8AE7E9B329F09174 /* Build */, + ); + sourceTree = ""; + }; + AF64E60ED33C9E5DC5DB4C21 /* Products */ = { + isa = PBXGroup; + children = ( + 4165F882B6F541E12DBD6A0D /* peg */, + C9B3F1D07DD720C50DE87DC5 /* leg */, + ); + name = Products; + sourceTree = ""; + }; + E2D71C5771542F758C302162 /* Source */ = { + isa = PBXGroup; + children = ( + D4BAF07C3AF28E51DD58E853 /* compile.c */, + 454F9F599E7B65F90C62CF9C /* leg.c */, + 27FA3C119507A9A914A66936 /* peg.c */, + E503317C684EFEB3E7E03861 /* tree.c */, + ); + name = Source; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 050EA9DBA8F5C296C3E39B8A /* peg */ = { + isa = PBXNativeTarget; + buildConfigurationList = EF4B00311D83FC2C01B276A4 /* Build configuration list for PBXNativeTarget "peg" */; + buildPhases = ( + 74AA795D8990365CCE282118 /* Sources */, + 97D5812F2529A3E39CE17CDE /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = peg; + productName = peg; + productReference = 4165F882B6F541E12DBD6A0D /* peg */; + productType = "com.apple.product-type.tool"; + }; + 84A1E5C1231D1E337ED0FC84 /* leg */ = { + isa = PBXNativeTarget; + buildConfigurationList = F7568C4D321FF46C2F4B43FB /* Build configuration list for PBXNativeTarget "leg" */; + buildPhases = ( + 915DAD0C515729956FE2BC69 /* Sources */, + 3DF86BD64E76AD4F8D892CF6 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = leg; + productName = leg; + productReference = C9B3F1D07DD720C50DE87DC5 /* leg */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + D23EA86C97C1C940E2591A06 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = YES; + }; + buildConfigurationList = 283B121430353A60CB56914F /* Build configuration list for PBXProject "peg" */; + compatibilityVersion = "Xcode 3.2"; + hasScannedForEncodings = 1; + mainGroup = AB7FD4EAF4FFE1A1CE63E31B; + projectDirPath = ""; + projectRoot = ""; + targets = ( + EFBC7368F96EACB75989C21D /* All */, + 050EA9DBA8F5C296C3E39B8A /* peg */, + 84A1E5C1231D1E337ED0FC84 /* leg */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 74AA795D8990365CCE282118 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 7921C7C2AD25A4A4C02470F5 /* peg.c in Sources */, + 8B61C6AE75A1750C17350E64 /* tree.c in Sources */, + 4D30CEABCD51397A50F65058 /* compile.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 915DAD0C515729956FE2BC69 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D8C3FFD80B6642D8BB341B90 /* leg.c in Sources */, + 3FE25C706AB45972C102CBB4 /* tree.c in Sources */, + 2D4E663DE432A398FC78635B /* compile.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 3DF530CEA77A591E4DFBFF2F /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 84A1E5C1231D1E337ED0FC84 /* leg */; + targetProxy = 12CD2CA862C5C1693300D7EF /* PBXContainerItemProxy */; + }; + B85F90055126E00C1334834C /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 050EA9DBA8F5C296C3E39B8A /* peg */; + targetProxy = 22C9A5E8EF76D4B801BB24E5 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 05AA053A004215362908ED84 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = ""; + GCC_PREPROCESSOR_DEFINITIONS = "\"NDEBUG\""; + PRODUCT_NAME = peg; + }; + name = Release; + }; + 2CB45BB7949774F10834EB3B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + INTERMEDIATE_DIR = "$(PROJECT_DERIVED_FILE_DIR)/$(CONFIGURATION)"; + SHARED_INTERMEDIATE_DIR = "$(SYMROOT)/DerivedSources/$(CONFIGURATION)"; + }; + name = Release; + }; + 7C93F597151F1782DBAF2E6E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + INTERMEDIATE_DIR = "$(PROJECT_DERIVED_FILE_DIR)/$(CONFIGURATION)"; + SHARED_INTERMEDIATE_DIR = "$(SYMROOT)/DerivedSources/$(CONFIGURATION)"; + }; + name = Debug; + }; + 879858F43394AA4CEFDC7263 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = ""; + GCC_PREPROCESSOR_DEFINITIONS = "\"NDEBUG\""; + PRODUCT_NAME = leg; + }; + name = Release; + }; + 8CF09EF6E825DDB8D49A6EA9 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = All; + }; + name = Release; + }; + DEFEA64AA5600BECDDA9A939 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = All; + }; + name = Debug; + }; + E2B1202070FAC019FA0BF2ED /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = ""; + GCC_PREPROCESSOR_DEFINITIONS = "\"DEBUG\""; + PRODUCT_NAME = leg; + }; + name = Debug; + }; + F41144D27A6369001B96C713 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + EXECUTABLE_PREFIX = ""; + GCC_PREPROCESSOR_DEFINITIONS = "\"DEBUG\""; + PRODUCT_NAME = peg; + }; + name = Debug; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 007E1122105A105C63F8A59F /* Build configuration list for PBXAggregateTarget "All" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + DEFEA64AA5600BECDDA9A939 /* Debug */, + 8CF09EF6E825DDB8D49A6EA9 /* Release */, + ); + defaultConfigurationIsVisible = 1; + defaultConfigurationName = Debug; + }; + 283B121430353A60CB56914F /* Build configuration list for PBXProject "peg" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 7C93F597151F1782DBAF2E6E /* Debug */, + 2CB45BB7949774F10834EB3B /* Release */, + ); + defaultConfigurationIsVisible = 1; + defaultConfigurationName = Debug; + }; + EF4B00311D83FC2C01B276A4 /* Build configuration list for PBXNativeTarget "peg" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F41144D27A6369001B96C713 /* Debug */, + 05AA053A004215362908ED84 /* Release */, + ); + defaultConfigurationIsVisible = 1; + defaultConfigurationName = Debug; + }; + F7568C4D321FF46C2F4B43FB /* Build configuration list for PBXNativeTarget "leg" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E2B1202070FAC019FA0BF2ED /* Debug */, + 879858F43394AA4CEFDC7263 /* Release */, + ); + defaultConfigurationIsVisible = 1; + defaultConfigurationName = Debug; + }; +/* End XCConfigurationList section */ + }; + rootObject = D23EA86C97C1C940E2591A06 /* Project object */; +} diff --git a/peg-0.1.9/compile.c b/peg-0.1.18/src/compile.c similarity index 53% rename from peg-0.1.9/compile.c rename to peg-0.1.18/src/compile.c index 74506b76..af734d26 100644 --- a/peg-0.1.9/compile.c +++ b/peg-0.1.18/src/compile.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2007, 2012 by Ian Piumarta +/* Copyright (c) 2007--2013 by Ian Piumarta * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -13,7 +13,7 @@ * * THE SOFTWARE IS PROVIDED 'AS IS'. USE ENTIRELY AT YOUR OWN RISK. * - * Last edited: 2012-04-29 16:09:36 by piumarta on emilia + * Last edited: 2016-07-22 09:43:05 by piumarta on zora.local */ #include @@ -21,6 +21,11 @@ #include #include +#ifdef WIN32 +# undef inline +# define inline __inline +#endif + #include "version.h" #include "tree.h" @@ -35,7 +40,16 @@ static void charClassClear(unsigned char bits[], int c) { bits[c >> 3] &= ~(1 << typedef void (*setter)(unsigned char bits[], int c); -static inline int oigit(int c) { return '0' <= c && c <= '7'; } +static inline int oigit(int c) { return ('0' <= c && c <= '7'); } +static inline int higit(int c) { return ('0' <= c && c <= '9') || ('A' <= c && c <= 'F') || ('a' <= c && c <= 'f'); } + +static inline int hexval(int c) +{ + if ('0' <= c && c <= '9') return c - '0'; + if ('A' <= c && c <= 'F') return 10 - 'A' + c; + if ('a' <= c && c <= 'f') return 10 - 'a' + c; + return 0; +} static int cnext(unsigned char **ccp) { @@ -47,14 +61,19 @@ static int cnext(unsigned char **ccp) { switch (c= *cclass++) { - case 'a': c= '\a'; break; /* bel */ - case 'b': c= '\b'; break; /* bs */ - case 'e': c= '\e'; break; /* esc */ - case 'f': c= '\f'; break; /* ff */ - case 'n': c= '\n'; break; /* nl */ - case 'r': c= '\r'; break; /* cr */ - case 't': c= '\t'; break; /* ht */ - case 'v': c= '\v'; break; /* vt */ + case 'a': c= '\a'; break; /* bel */ + case 'b': c= '\b'; break; /* bs */ + case 'e': c= '\033'; break; /* esc */ + case 'f': c= '\f'; break; /* ff */ + case 'n': c= '\n'; break; /* nl */ + case 'r': c= '\r'; break; /* cr */ + case 't': c= '\t'; break; /* ht */ + case 'v': c= '\v'; break; /* vt */ + case 'x': + c= 0; + if (higit(*cclass)) c= (c << 4) + hexval(*cclass++); + if (higit(*cclass)) c= (c << 4) + hexval(*cclass++); + break; default: if (oigit(c)) { @@ -117,8 +136,8 @@ static void begin(void) { fprintf(output, "\n {"); } static void end(void) { fprintf(output, "\n }"); } static void label(int n) { fprintf(output, "\n l%d:;\t", n); } static void jump(int n) { fprintf(output, " goto l%d;", n); } -static void save(int n) { fprintf(output, " int yypos%d= ctx->pos, yythunkpos%d= ctx->thunkpos;", n, n); } -static void restore(int n) { fprintf(output, " ctx->pos= yypos%d; ctx->thunkpos= yythunkpos%d;", n, n); } +static void save(int n) { fprintf(output, " int yypos%d= yy->__pos, yythunkpos%d= yy->__thunkpos;", n, n); } +static void restore(int n) { fprintf(output, " yy->__pos= yypos%d; yy->__thunkpos= yythunkpos%d;", n, n); } static void Node_compile_c_ko(Node *node, int ko) { @@ -131,13 +150,13 @@ static void Node_compile_c_ko(Node *node, int ko) break; case Dot: - fprintf(output, " if (!yymatchDot(ctx)) goto l%d;", ko); + fprintf(output, " if (!yymatchDot(yy)) goto l%d;", ko); break; case Name: - fprintf(output, " if (!yy_%s(ctx)) goto l%d;", node->name.rule->rule.name, ko); + fprintf(output, " if (!yy_%s(yy)) goto l%d;", node->name.rule->rule.name, ko); if (node->name.variable) - fprintf(output, " yyDo(ctx, yySet, %d, 0);", node->name.variable->variable.offset); + fprintf(output, " yyDo(yy, yySet, %d, 0);", node->name.variable->variable.offset); break; case Character: @@ -147,28 +166,61 @@ static void Node_compile_c_ko(Node *node, int ko) if (1 == len) { if ('\'' == node->string.value[0]) - fprintf(output, " if (!yymatchChar(ctx, '\\'')) goto l%d;", ko); + fprintf(output, " if (!yymatchChar(yy, '\\'')) goto l%d;", ko); else - fprintf(output, " if (!yymatchChar(ctx, '%s')) goto l%d;", node->string.value, ko); + fprintf(output, " if (!yymatchChar(yy, '%s')) goto l%d;", node->string.value, ko); } else if (2 == len && '\\' == node->string.value[0]) - fprintf(output, " if (!yymatchChar(ctx, '%s')) goto l%d;", node->string.value, ko); - else - fprintf(output, " if (!yymatchString(ctx, \"%s\")) goto l%d;", node->string.value, ko); + fprintf(output, " if (!yymatchChar(yy, '%s')) goto l%d;", node->string.value, ko); + else + fprintf(output, " if (!yymatchString(yy, \"%s\")) goto l%d;", node->string.value, ko); } break; case Class: - fprintf(output, " if (!yymatchClass(ctx, (unsigned char *)\"%s\")) goto l%d;", makeCharClass(node->cclass.value), ko); + fprintf(output, " if (!yymatchClass(yy, (unsigned char *)\"%s\")) goto l%d;", makeCharClass(node->cclass.value), ko); break; case Action: - fprintf(output, " yyDo(ctx, yy%s, ctx->begin, ctx->end);", node->action.name); + fprintf(output, " yyDo(yy, yy%s, yy->__begin, yy->__end);", node->action.name); + break; + + case Inline: + fprintf(output, " yyText(yy, yy->__begin, yy->__end);\n"); + fprintf(output, "#define yytext yy->__text\n"); + fprintf(output, "#define yyleng yy->__textlen\n"); + fprintf(output, "%s;\n", node->inLine.text); + fprintf(output, "#undef yytext\n"); + fprintf(output, "#undef yyleng\n"); break; case Predicate: - fprintf(output, " yyText(ctx, ctx->begin, ctx->end); if (!(%s)) goto l%d;", node->action.text, ko); + fprintf(output, " yyText(yy, yy->__begin, yy->__end); {\n"); + fprintf(output, "#define yytext yy->__text\n"); + fprintf(output, "#define yyleng yy->__textlen\n"); + fprintf(output, "if (!(%s)) goto l%d;\n", node->predicate.text, ko); + fprintf(output, "#undef yytext\n"); + fprintf(output, "#undef yyleng\n"); + fprintf(output, " }"); + break; + + case Error: + { + int eok= yyl(), eko= yyl(); + Node_compile_c_ko(node->error.element, eko); + jump(eok); + label(eko); + fprintf(output, " yyText(yy, yy->__begin, yy->__end); {\n"); + fprintf(output, "#define yytext yy->__text\n"); + fprintf(output, "#define yyleng yy->__textlen\n"); + fprintf(output, " %s;\n", node->error.text); + fprintf(output, "#undef yytext\n"); + fprintf(output, "#undef yyleng\n"); + fprintf(output, " }"); + jump(ko); + label(eok); + } break; case Alternate: @@ -287,13 +339,13 @@ static void defineVariables(Node *node) int count= 0; while (node) { - fprintf(output, "#define %s ctx->val[%d]\n", node->variable.name, --count); + fprintf(output, "#define %s yy->__val[%d]\n", node->variable.name, --count); node->variable.offset= count; node= node->variable.next; } - fprintf(output, "#define yy ctx->yy\n"); - fprintf(output, "#define yypos ctx->pos\n"); - fprintf(output, "#define yythunkpos ctx->thunkpos\n"); + fprintf(output, "#define __ yy->__\n"); + fprintf(output, "#define yypos yy->__pos\n"); + fprintf(output, "#define yythunkpos yy->__thunkpos\n"); } static void undefineVariables(Node *node) @@ -325,21 +377,21 @@ static void Rule_compile_c2(Node *node) safe= ((Query == node->rule.expression->type) || (Star == node->rule.expression->type)); - fprintf(output, "\nYY_RULE(int) yy_%s(yycontext *ctx)\n{", node->rule.name); + fprintf(output, "\nYY_RULE(int) yy_%s(yycontext *yy)\n{", node->rule.name); if (!safe) save(0); if (node->rule.variables) - fprintf(output, " yyDo(ctx, yyPush, %d, 0);", countVariables(node->rule.variables)); + fprintf(output, " yyDo(yy, yyPush, %d, 0);", countVariables(node->rule.variables)); fprintf(output, "\n yyprintf((stderr, \"%%s\\n\", \"%s\"));", node->rule.name); Node_compile_c_ko(node->rule.expression, ko); - fprintf(output, "\n yyprintf((stderr, \" ok %%s @ %%s\\n\", \"%s\", ctx->buf+ctx->pos));", node->rule.name); + fprintf(output, "\n yyprintf((stderr, \" ok %%s @ %%s\\n\", \"%s\", yy->__buf+yy->__pos));", node->rule.name); if (node->rule.variables) - fprintf(output, " yyDo(ctx, yyPop, %d, 0);", countVariables(node->rule.variables)); + fprintf(output, " yyDo(yy, yyPop, %d, 0);", countVariables(node->rule.variables)); fprintf(output, "\n return 1;"); if (!safe) { label(ko); restore(0); - fprintf(output, "\n yyprintf((stderr, \" fail %%s @ %%s\\n\", \"%s\", ctx->buf+ctx->pos));", node->rule.name); + fprintf(output, "\n yyprintf((stderr, \" fail %%s @ %%s\\n\", \"%s\", yy->__buf+yy->__pos));", node->rule.name); fprintf(output, "\n return 0;"); } fprintf(output, "\n}"); @@ -356,6 +408,15 @@ static char *header= "\ "; static char *preamble= "\ +#ifndef YY_MALLOC\n\ +#define YY_MALLOC(C, N) malloc(N)\n\ +#endif\n\ +#ifndef YY_REALLOC\n\ +#define YY_REALLOC(C, P, N) realloc(P, N)\n\ +#endif\n\ +#ifndef YY_FREE\n\ +#define YY_FREE(C, P) free(P)\n\ +#endif\n\ #ifndef YY_LOCAL\n\ #define YY_LOCAL(T) static T\n\ #endif\n\ @@ -374,19 +435,14 @@ static char *preamble= "\ #ifndef YYPARSEFROM\n\ #define YYPARSEFROM yyparsefrom\n\ #endif\n\ -#ifndef YY_INPUT\n\ -#define YY_INPUT(buf, result, max_size) \\\n\ - { \\\n\ - int yyc= getchar(); \\\n\ - result= (EOF == yyc) ? 0 : (*(buf)= yyc, 1); \\\n\ - yyprintf((stderr, \"<%c>\", yyc)); \\\n\ - }\n\ +#ifndef YYRELEASE\n\ +#define YYRELEASE yyrelease\n\ #endif\n\ #ifndef YY_BEGIN\n\ -#define YY_BEGIN ( ctx->begin= ctx->pos, 1)\n\ +#define YY_BEGIN ( yy->__begin= yy->__pos, 1)\n\ #endif\n\ #ifndef YY_END\n\ -#define YY_END ( ctx->end= ctx->pos, 1)\n\ +#define YY_END ( yy->__end= yy->__pos, 1)\n\ #endif\n\ #ifdef YY_DEBUG\n\ # define yyprintf(args) fprintf args\n\ @@ -396,30 +452,37 @@ static char *preamble= "\ #ifndef YYSTYPE\n\ #define YYSTYPE int\n\ #endif\n\ +#ifndef YY_STACK_SIZE\n\ +#define YY_STACK_SIZE 128\n\ +#endif\n\ +\n\ +#ifndef YY_BUFFER_SIZE\n\ +#define YY_BUFFER_SIZE 1024\n\ +#endif\n\ \n\ #ifndef YY_PART\n\ \n\ typedef struct _yycontext yycontext;\n\ -typedef void (*yyaction)(yycontext *ctx, char *yytext, int yyleng);\n\ +typedef void (*yyaction)(yycontext *yy, char *yytext, int yyleng);\n\ typedef struct _yythunk { int begin, end; yyaction action; struct _yythunk *next; } yythunk;\n\ \n\ struct _yycontext {\n\ - char *buf;\n\ - int buflen;\n\ - int pos;\n\ - int limit;\n\ - char *text;\n\ - int textlen;\n\ - int begin;\n\ - int end;\n\ - int textmax;\n\ - yythunk *thunks;\n\ - int thunkslen;\n\ - int thunkpos;\n\ - YYSTYPE yy;\n\ - YYSTYPE *val;\n\ - YYSTYPE *vals;\n\ - int valslen;\n\ + char *__buf;\n\ + int __buflen;\n\ + int __pos;\n\ + int __limit;\n\ + char *__text;\n\ + int __textlen;\n\ + int __begin;\n\ + int __end;\n\ + int __textmax;\n\ + yythunk *__thunks;\n\ + int __thunkslen;\n\ + int __thunkpos;\n\ + YYSTYPE __;\n\ + YYSTYPE *__val;\n\ + YYSTYPE *__vals;\n\ + int __valslen;\n\ #ifdef YY_CTX_MEMBERS\n\ YY_CTX_MEMBERS\n\ #endif\n\ @@ -430,137 +493,157 @@ struct _yycontext {\n\ #define YY_CTX_PARAM yycontext *yyctx\n\ #define YY_CTX_ARG_ yyctx,\n\ #define YY_CTX_ARG yyctx\n\ +#ifndef YY_INPUT\n\ +#define YY_INPUT(yy, buf, result, max_size) \\\n\ + { \\\n\ + int yyc= getchar(); \\\n\ + result= (EOF == yyc) ? 0 : (*(buf)= yyc, 1); \\\n\ + yyprintf((stderr, \"<%c>\", yyc)); \\\n\ + }\n\ +#endif\n\ #else\n\ #define YY_CTX_PARAM_\n\ #define YY_CTX_PARAM\n\ #define YY_CTX_ARG_\n\ #define YY_CTX_ARG\n\ -yycontext yyctx0;\n\ -yycontext *yyctx= &yyctx0;\n\ +yycontext _yyctx= { 0, 0 };\n\ +yycontext *yyctx= &_yyctx;\n\ +#ifndef YY_INPUT\n\ +#define YY_INPUT(buf, result, max_size) \\\n\ + { \\\n\ + int yyc= getchar(); \\\n\ + result= (EOF == yyc) ? 0 : (*(buf)= yyc, 1); \\\n\ + yyprintf((stderr, \"<%c>\", yyc)); \\\n\ + }\n\ +#endif\n\ #endif\n\ \n\ -YY_LOCAL(int) yyrefill(yycontext *ctx)\n\ +YY_LOCAL(int) yyrefill(yycontext *yy)\n\ {\n\ int yyn;\n\ - while (ctx->buflen - ctx->pos < 512)\n\ + while (yy->__buflen - yy->__pos < 512)\n\ {\n\ - ctx->buflen *= 2;\n\ - ctx->buf= (char *)realloc(ctx->buf, ctx->buflen);\n\ + yy->__buflen *= 2;\n\ + yy->__buf= (char *)YY_REALLOC(yy, yy->__buf, yy->__buflen);\n\ }\n\ - YY_INPUT((ctx->buf + ctx->pos), yyn, (ctx->buflen - ctx->pos));\n\ +#ifdef YY_CTX_LOCAL\n\ + YY_INPUT(yy, (yy->__buf + yy->__pos), yyn, (yy->__buflen - yy->__pos));\n\ +#else\n\ + YY_INPUT((yy->__buf + yy->__pos), yyn, (yy->__buflen - yy->__pos));\n\ +#endif\n\ if (!yyn) return 0;\n\ - ctx->limit += yyn;\n\ + yy->__limit += yyn;\n\ return 1;\n\ }\n\ \n\ -YY_LOCAL(int) yymatchDot(yycontext *ctx)\n\ +YY_LOCAL(int) yymatchDot(yycontext *yy)\n\ {\n\ - if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0;\n\ - ++ctx->pos;\n\ + if (yy->__pos >= yy->__limit && !yyrefill(yy)) return 0;\n\ + ++yy->__pos;\n\ return 1;\n\ }\n\ \n\ -YY_LOCAL(int) yymatchChar(yycontext *ctx, int c)\n\ +YY_LOCAL(int) yymatchChar(yycontext *yy, int c)\n\ {\n\ - if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0;\n\ - if ((unsigned char)ctx->buf[ctx->pos] == c)\n\ + if (yy->__pos >= yy->__limit && !yyrefill(yy)) return 0;\n\ + if ((unsigned char)yy->__buf[yy->__pos] == c)\n\ {\n\ - ++ctx->pos;\n\ - yyprintf((stderr, \" ok yymatchChar(ctx, %c) @ %s\\n\", c, ctx->buf+ctx->pos));\n\ + ++yy->__pos;\n\ + yyprintf((stderr, \" ok yymatchChar(yy, %c) @ %s\\n\", c, yy->__buf+yy->__pos));\n\ return 1;\n\ }\n\ - yyprintf((stderr, \" fail yymatchChar(ctx, %c) @ %s\\n\", c, ctx->buf+ctx->pos));\n\ + yyprintf((stderr, \" fail yymatchChar(yy, %c) @ %s\\n\", c, yy->__buf+yy->__pos));\n\ return 0;\n\ }\n\ \n\ -YY_LOCAL(int) yymatchString(yycontext *ctx, char *s)\n\ +YY_LOCAL(int) yymatchString(yycontext *yy, const char *s)\n\ {\n\ - int yysav= ctx->pos;\n\ + int yysav= yy->__pos;\n\ while (*s)\n\ {\n\ - if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0;\n\ - if (ctx->buf[ctx->pos] != *s)\n\ + if (yy->__pos >= yy->__limit && !yyrefill(yy)) return 0;\n\ + if (yy->__buf[yy->__pos] != *s)\n\ {\n\ - ctx->pos= yysav;\n\ + yy->__pos= yysav;\n\ return 0;\n\ }\n\ ++s;\n\ - ++ctx->pos;\n\ + ++yy->__pos;\n\ }\n\ return 1;\n\ }\n\ \n\ -YY_LOCAL(int) yymatchClass(yycontext *ctx, unsigned char *bits)\n\ +YY_LOCAL(int) yymatchClass(yycontext *yy, unsigned char *bits)\n\ {\n\ int c;\n\ - if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0;\n\ - c= (unsigned char)ctx->buf[ctx->pos];\n\ + if (yy->__pos >= yy->__limit && !yyrefill(yy)) return 0;\n\ + c= (unsigned char)yy->__buf[yy->__pos];\n\ if (bits[c >> 3] & (1 << (c & 7)))\n\ {\n\ - ++ctx->pos;\n\ - yyprintf((stderr, \" ok yymatchClass @ %s\\n\", ctx->buf+ctx->pos));\n\ + ++yy->__pos;\n\ + yyprintf((stderr, \" ok yymatchClass @ %s\\n\", yy->__buf+yy->__pos));\n\ return 1;\n\ }\n\ - yyprintf((stderr, \" fail yymatchClass @ %s\\n\", ctx->buf+ctx->pos));\n\ + yyprintf((stderr, \" fail yymatchClass @ %s\\n\", yy->__buf+yy->__pos));\n\ return 0;\n\ }\n\ \n\ -YY_LOCAL(void) yyDo(yycontext *ctx, yyaction action, int begin, int end)\n\ +YY_LOCAL(void) yyDo(yycontext *yy, yyaction action, int begin, int end)\n\ {\n\ - while (ctx->thunkpos >= ctx->thunkslen)\n\ + while (yy->__thunkpos >= yy->__thunkslen)\n\ {\n\ - ctx->thunkslen *= 2;\n\ - ctx->thunks= (yythunk *)realloc(ctx->thunks, sizeof(yythunk) * ctx->thunkslen);\n\ + yy->__thunkslen *= 2;\n\ + yy->__thunks= (yythunk *)YY_REALLOC(yy, yy->__thunks, sizeof(yythunk) * yy->__thunkslen);\n\ }\n\ - ctx->thunks[ctx->thunkpos].begin= begin;\n\ - ctx->thunks[ctx->thunkpos].end= end;\n\ - ctx->thunks[ctx->thunkpos].action= action;\n\ - ++ctx->thunkpos;\n\ + yy->__thunks[yy->__thunkpos].begin= begin;\n\ + yy->__thunks[yy->__thunkpos].end= end;\n\ + yy->__thunks[yy->__thunkpos].action= action;\n\ + ++yy->__thunkpos;\n\ }\n\ \n\ -YY_LOCAL(int) yyText(yycontext *ctx, int begin, int end)\n\ +YY_LOCAL(int) yyText(yycontext *yy, int begin, int end)\n\ {\n\ int yyleng= end - begin;\n\ if (yyleng <= 0)\n\ yyleng= 0;\n\ else\n\ {\n\ - while (ctx->textlen < (yyleng + 1))\n\ + while (yy->__textlen < (yyleng + 1))\n\ {\n\ - ctx->textlen *= 2;\n\ - ctx->text= (char *)realloc(ctx->text, ctx->textlen);\n\ + yy->__textlen *= 2;\n\ + yy->__text= (char *)YY_REALLOC(yy, yy->__text, yy->__textlen);\n\ }\n\ - memcpy(ctx->text, ctx->buf + begin, yyleng);\n\ + memcpy(yy->__text, yy->__buf + begin, yyleng);\n\ }\n\ - ctx->text[yyleng]= '\\0';\n\ + yy->__text[yyleng]= '\\0';\n\ return yyleng;\n\ }\n\ \n\ -YY_LOCAL(void) yyDone(yycontext *ctx)\n\ +YY_LOCAL(void) yyDone(yycontext *yy)\n\ {\n\ int pos;\n\ - for (pos= 0; pos < ctx->thunkpos; ++pos)\n\ + for (pos= 0; pos < yy->__thunkpos; ++pos)\n\ {\n\ - yythunk *thunk= &ctx->thunks[pos];\n\ - int yyleng= thunk->end ? yyText(ctx, thunk->begin, thunk->end) : thunk->begin;\n\ - yyprintf((stderr, \"DO [%d] %p %s\\n\", pos, thunk->action, ctx->text));\n\ - thunk->action(ctx, ctx->text, yyleng);\n\ + yythunk *thunk= &yy->__thunks[pos];\n\ + int yyleng= thunk->end ? yyText(yy, thunk->begin, thunk->end) : thunk->begin;\n\ + yyprintf((stderr, \"DO [%d] %p %s\\n\", pos, thunk->action, yy->__text));\n\ + thunk->action(yy, yy->__text, yyleng);\n\ }\n\ - ctx->thunkpos= 0;\n\ + yy->__thunkpos= 0;\n\ }\n\ \n\ -YY_LOCAL(void) yyCommit(yycontext *ctx)\n\ +YY_LOCAL(void) yyCommit(yycontext *yy)\n\ {\n\ - if ((ctx->limit -= ctx->pos))\n\ + if ((yy->__limit -= yy->__pos))\n\ {\n\ - memmove(ctx->buf, ctx->buf + ctx->pos, ctx->limit);\n\ + memmove(yy->__buf, yy->__buf + yy->__pos, yy->__limit);\n\ }\n\ - ctx->begin -= ctx->pos;\n\ - ctx->end -= ctx->pos;\n\ - ctx->pos= ctx->thunkpos= 0;\n\ + yy->__begin -= yy->__pos;\n\ + yy->__end -= yy->__pos;\n\ + yy->__pos= yy->__thunkpos= 0;\n\ }\n\ \n\ -YY_LOCAL(int) yyAccept(yycontext *ctx, int tp0)\n\ +YY_LOCAL(int) yyAccept(yycontext *yy, int tp0)\n\ {\n\ if (tp0)\n\ {\n\ @@ -569,19 +652,29 @@ YY_LOCAL(int) yyAccept(yycontext *ctx, int tp0)\n\ }\n\ else\n\ {\n\ - yyDone(ctx);\n\ - yyCommit(ctx);\n\ + yyDone(yy);\n\ + yyCommit(yy);\n\ }\n\ return 1;\n\ }\n\ \n\ -YY_LOCAL(void) yyPush(yycontext *ctx, char *text, int count) { ctx->val += count; }\n\ -YY_LOCAL(void) yyPop(yycontext *ctx, char *text, int count) { ctx->val -= count; }\n\ -YY_LOCAL(void) yySet(yycontext *ctx, char *text, int count) { ctx->val[count]= ctx->yy; }\n\ +YY_LOCAL(void) yyPush(yycontext *yy, char *text, int count)\n\ +{\n\ + yy->__val += count;\n\ + while (yy->__valslen <= yy->__val - yy->__vals)\n\ + {\n\ + long offset= yy->__val - yy->__vals;\n\ + yy->__valslen *= 2;\n\ + yy->__vals= (YYSTYPE *)YY_REALLOC(yy, yy->__vals, sizeof(YYSTYPE) * yy->__valslen);\n\ + yy->__val= yy->__vals + offset;\n\ + }\n\ +}\n\ +YY_LOCAL(void) yyPop(yycontext *yy, char *text, int count) { yy->__val -= count; }\n\ +YY_LOCAL(void) yySet(yycontext *yy, char *text, int count) { yy->__val[count]= yy->__; }\n\ \n\ #endif /* YY_PART */\n\ \n\ -#define YYACCEPT yyAccept(ctx, yythunkpos0)\n\ +#define YYACCEPT yyAccept(yy, yythunkpos0)\n\ \n\ "; @@ -589,26 +682,26 @@ static char *footer= "\n\ \n\ #ifndef YY_PART\n\ \n\ -typedef int (*yyrule)(yycontext *ctx);\n\ +typedef int (*yyrule)(yycontext *yy);\n\ \n\ YY_PARSE(int) YYPARSEFROM(YY_CTX_PARAM_ yyrule yystart)\n\ {\n\ int yyok;\n\ - if (!yyctx->buflen)\n\ + if (!yyctx->__buflen)\n\ {\n\ - yyctx->buflen= 1024;\n\ - yyctx->buf= (char *)malloc(yyctx->buflen);\n\ - yyctx->textlen= 1024;\n\ - yyctx->text= (char *)malloc(yyctx->textlen);\n\ - yyctx->thunkslen= 32;\n\ - yyctx->thunks= (yythunk *)malloc(sizeof(yythunk) * yyctx->thunkslen);\n\ - yyctx->valslen= 32;\n\ - yyctx->vals= (YYSTYPE *)malloc(sizeof(YYSTYPE) * yyctx->valslen);\n\ - yyctx->begin= yyctx->end= yyctx->pos= yyctx->limit= yyctx->thunkpos= 0;\n\ + yyctx->__buflen= YY_BUFFER_SIZE;\n\ + yyctx->__buf= (char *)YY_MALLOC(yyctx, yyctx->__buflen);\n\ + yyctx->__textlen= YY_BUFFER_SIZE;\n\ + yyctx->__text= (char *)YY_MALLOC(yyctx, yyctx->__textlen);\n\ + yyctx->__thunkslen= YY_STACK_SIZE;\n\ + yyctx->__thunks= (yythunk *)YY_MALLOC(yyctx, sizeof(yythunk) * yyctx->__thunkslen);\n\ + yyctx->__valslen= YY_STACK_SIZE;\n\ + yyctx->__vals= (YYSTYPE *)YY_MALLOC(yyctx, sizeof(YYSTYPE) * yyctx->__valslen);\n\ + yyctx->__begin= yyctx->__end= yyctx->__pos= yyctx->__limit= yyctx->__thunkpos= 0;\n\ }\n\ - yyctx->begin= yyctx->end= yyctx->pos;\n\ - yyctx->thunkpos= 0;\n\ - yyctx->val= yyctx->vals;\n\ + yyctx->__begin= yyctx->__end= yyctx->__pos;\n\ + yyctx->__thunkpos= 0;\n\ + yyctx->__val= yyctx->__vals;\n\ yyok= yystart(yyctx);\n\ if (yyok) yyDone(yyctx);\n\ yyCommit(yyctx);\n\ @@ -620,6 +713,19 @@ YY_PARSE(int) YYPARSE(YY_CTX_PARAM)\n\ return YYPARSEFROM(YY_CTX_ARG_ yy_%s);\n\ }\n\ \n\ +YY_PARSE(yycontext *) YYRELEASE(yycontext *yyctx)\n\ +{\n\ + if (yyctx->__buflen)\n\ + {\n\ + yyctx->__buflen= 0;\n\ + YY_FREE(yyctx, yyctx->__buf);\n\ + YY_FREE(yyctx, yyctx->__text);\n\ + YY_FREE(yyctx, yyctx->__thunks);\n\ + YY_FREE(yyctx, yyctx->__vals);\n\ + }\n\ + return yyctx;\n\ +}\n\ +\n\ #endif\n\ "; @@ -658,7 +764,9 @@ int consumesInput(Node *node) case String: return strlen(node->string.value) > 0; case Class: return 1; case Action: return 0; + case Inline: return 0; case Predicate: return 0; + case Error: return consumesInput(node->error.element); case Alternate: { @@ -692,7 +800,7 @@ int consumesInput(Node *node) } -void Rule_compile_c(Node *node) +void Rule_compile_c(Node *node, int nolines) { Node *n; @@ -701,14 +809,18 @@ void Rule_compile_c(Node *node) fprintf(output, "%s", preamble); for (n= node; n; n= n->rule.next) - fprintf(output, "YY_RULE(int) yy_%s(yycontext *ctx); /* %d */\n", n->rule.name, n->rule.id); + fprintf(output, "YY_RULE(int) yy_%s(yycontext *yy); /* %d */\n", n->rule.name, n->rule.id); fprintf(output, "\n"); for (n= actions; n; n= n->action.list) { - fprintf(output, "YY_ACTION(void) yy%s(yycontext *ctx, char *yytext, int yyleng)\n{\n", n->action.name); + fprintf(output, "YY_ACTION(void) yy%s(yycontext *yy, char *yytext, int yyleng)\n{\n", n->action.name); defineVariables(n->action.rule->rule.variables); fprintf(output, " yyprintf((stderr, \"do yy%s\\n\"));\n", n->action.name); + fprintf(output, " {\n"); + if (!nolines) + fprintf(output, "#line %i\n", n->action.line); fprintf(output, " %s;\n", n->action.text); + fprintf(output, " }\n"); undefineVariables(n->action.rule->rule.variables); fprintf(output, "}\n"); } diff --git a/peg-0.1.18/src/leg.c b/peg-0.1.18/src/leg.c new file mode 100644 index 00000000..ab9a27f3 --- /dev/null +++ b/peg-0.1.18/src/leg.c @@ -0,0 +1,1556 @@ +/* A recursive-descent parser generated by peg 0.1.18 */ + +#include +#include +#include +#define YYRULECOUNT 39 +#line 20 "src/leg.leg" + +# include "tree.h" +# include "version.h" + +# include +# include +# include +# include +# include +# include + + typedef struct Header Header; + + struct Header { + int line; + char *text; + Header *next; + }; + + FILE *input= 0; + + int verboseFlag= 0; + int nolinesFlag= 0; + + static int lineNumber= 0; + static int headerLine= 0; + static int actionLine= 0; + static char *fileName= 0; + static int trailerLine= 0; + static char *trailer= 0; + static Header *headers= 0; + + void makeHeader(int line, char *text); + void makeTrailer(int line, char *text); + + void yyerror(char *message); + +# define YY_INPUT(buf, result, max) \ + { \ + int c= getc(input); \ + /* if ('\n' == c || '\r' == c) ++lineNumber; */ \ + result= (EOF == c) ? 0 : (*(buf)= c, 1); \ + } + +# define YY_LOCAL(T) static T +# define YY_RULE(T) static T + +#ifndef YY_MALLOC +#define YY_MALLOC(C, N) malloc(N) +#endif +#ifndef YY_REALLOC +#define YY_REALLOC(C, P, N) realloc(P, N) +#endif +#ifndef YY_FREE +#define YY_FREE(C, P) free(P) +#endif +#ifndef YY_LOCAL +#define YY_LOCAL(T) static T +#endif +#ifndef YY_ACTION +#define YY_ACTION(T) static T +#endif +#ifndef YY_RULE +#define YY_RULE(T) static T +#endif +#ifndef YY_PARSE +#define YY_PARSE(T) T +#endif +#ifndef YYPARSE +#define YYPARSE yyparse +#endif +#ifndef YYPARSEFROM +#define YYPARSEFROM yyparsefrom +#endif +#ifndef YYRELEASE +#define YYRELEASE yyrelease +#endif +#ifndef YY_BEGIN +#define YY_BEGIN ( yy->__begin= yy->__pos, 1) +#endif +#ifndef YY_END +#define YY_END ( yy->__end= yy->__pos, 1) +#endif +#ifdef YY_DEBUG +# define yyprintf(args) fprintf args +#else +# define yyprintf(args) +#endif +#ifndef YYSTYPE +#define YYSTYPE int +#endif +#ifndef YY_STACK_SIZE +#define YY_STACK_SIZE 128 +#endif + +#ifndef YY_BUFFER_SIZE +#define YY_BUFFER_SIZE 1024 +#endif + +#ifndef YY_PART + +typedef struct _yycontext yycontext; +typedef void (*yyaction)(yycontext *yy, char *yytext, int yyleng); +typedef struct _yythunk { int begin, end; yyaction action; struct _yythunk *next; } yythunk; + +struct _yycontext { + char *__buf; + int __buflen; + int __pos; + int __limit; + char *__text; + int __textlen; + int __begin; + int __end; + int __textmax; + yythunk *__thunks; + int __thunkslen; + int __thunkpos; + YYSTYPE __; + YYSTYPE *__val; + YYSTYPE *__vals; + int __valslen; +#ifdef YY_CTX_MEMBERS + YY_CTX_MEMBERS +#endif +}; + +#ifdef YY_CTX_LOCAL +#define YY_CTX_PARAM_ yycontext *yyctx, +#define YY_CTX_PARAM yycontext *yyctx +#define YY_CTX_ARG_ yyctx, +#define YY_CTX_ARG yyctx +#ifndef YY_INPUT +#define YY_INPUT(yy, buf, result, max_size) \ + { \ + int yyc= getchar(); \ + result= (EOF == yyc) ? 0 : (*(buf)= yyc, 1); \ + yyprintf((stderr, "<%c>", yyc)); \ + } +#endif +#else +#define YY_CTX_PARAM_ +#define YY_CTX_PARAM +#define YY_CTX_ARG_ +#define YY_CTX_ARG +yycontext _yyctx= { 0, 0 }; +yycontext *yyctx= &_yyctx; +#ifndef YY_INPUT +#define YY_INPUT(buf, result, max_size) \ + { \ + int yyc= getchar(); \ + result= (EOF == yyc) ? 0 : (*(buf)= yyc, 1); \ + yyprintf((stderr, "<%c>", yyc)); \ + } +#endif +#endif + +YY_LOCAL(int) yyrefill(yycontext *yy) +{ + int yyn; + while (yy->__buflen - yy->__pos < 512) + { + yy->__buflen *= 2; + yy->__buf= (char *)YY_REALLOC(yy, yy->__buf, yy->__buflen); + } +#ifdef YY_CTX_LOCAL + YY_INPUT(yy, (yy->__buf + yy->__pos), yyn, (yy->__buflen - yy->__pos)); +#else + YY_INPUT((yy->__buf + yy->__pos), yyn, (yy->__buflen - yy->__pos)); +#endif + if (!yyn) return 0; + yy->__limit += yyn; + return 1; +} + +YY_LOCAL(int) yymatchDot(yycontext *yy) +{ + if (yy->__pos >= yy->__limit && !yyrefill(yy)) return 0; + ++yy->__pos; + return 1; +} + +YY_LOCAL(int) yymatchChar(yycontext *yy, int c) +{ + if (yy->__pos >= yy->__limit && !yyrefill(yy)) return 0; + if ((unsigned char)yy->__buf[yy->__pos] == c) + { + ++yy->__pos; + yyprintf((stderr, " ok yymatchChar(yy, %c) @ %s\n", c, yy->__buf+yy->__pos)); + return 1; + } + yyprintf((stderr, " fail yymatchChar(yy, %c) @ %s\n", c, yy->__buf+yy->__pos)); + return 0; +} + +YY_LOCAL(int) yymatchString(yycontext *yy, const char *s) +{ + int yysav= yy->__pos; + while (*s) + { + if (yy->__pos >= yy->__limit && !yyrefill(yy)) return 0; + if (yy->__buf[yy->__pos] != *s) + { + yy->__pos= yysav; + return 0; + } + ++s; + ++yy->__pos; + } + return 1; +} + +YY_LOCAL(int) yymatchClass(yycontext *yy, unsigned char *bits) +{ + int c; + if (yy->__pos >= yy->__limit && !yyrefill(yy)) return 0; + c= (unsigned char)yy->__buf[yy->__pos]; + if (bits[c >> 3] & (1 << (c & 7))) + { + ++yy->__pos; + yyprintf((stderr, " ok yymatchClass @ %s\n", yy->__buf+yy->__pos)); + return 1; + } + yyprintf((stderr, " fail yymatchClass @ %s\n", yy->__buf+yy->__pos)); + return 0; +} + +YY_LOCAL(void) yyDo(yycontext *yy, yyaction action, int begin, int end) +{ + while (yy->__thunkpos >= yy->__thunkslen) + { + yy->__thunkslen *= 2; + yy->__thunks= (yythunk *)YY_REALLOC(yy, yy->__thunks, sizeof(yythunk) * yy->__thunkslen); + } + yy->__thunks[yy->__thunkpos].begin= begin; + yy->__thunks[yy->__thunkpos].end= end; + yy->__thunks[yy->__thunkpos].action= action; + ++yy->__thunkpos; +} + +YY_LOCAL(int) yyText(yycontext *yy, int begin, int end) +{ + int yyleng= end - begin; + if (yyleng <= 0) + yyleng= 0; + else + { + while (yy->__textlen < (yyleng + 1)) + { + yy->__textlen *= 2; + yy->__text= (char *)YY_REALLOC(yy, yy->__text, yy->__textlen); + } + memcpy(yy->__text, yy->__buf + begin, yyleng); + } + yy->__text[yyleng]= '\0'; + return yyleng; +} + +YY_LOCAL(void) yyDone(yycontext *yy) +{ + int pos; + for (pos= 0; pos < yy->__thunkpos; ++pos) + { + yythunk *thunk= &yy->__thunks[pos]; + int yyleng= thunk->end ? yyText(yy, thunk->begin, thunk->end) : thunk->begin; + yyprintf((stderr, "DO [%d] %p %s\n", pos, thunk->action, yy->__text)); + thunk->action(yy, yy->__text, yyleng); + } + yy->__thunkpos= 0; +} + +YY_LOCAL(void) yyCommit(yycontext *yy) +{ + if ((yy->__limit -= yy->__pos)) + { + memmove(yy->__buf, yy->__buf + yy->__pos, yy->__limit); + } + yy->__begin -= yy->__pos; + yy->__end -= yy->__pos; + yy->__pos= yy->__thunkpos= 0; +} + +YY_LOCAL(int) yyAccept(yycontext *yy, int tp0) +{ + if (tp0) + { + fprintf(stderr, "accept denied at %d\n", tp0); + return 0; + } + else + { + yyDone(yy); + yyCommit(yy); + } + return 1; +} + +YY_LOCAL(void) yyPush(yycontext *yy, char *text, int count) +{ + yy->__val += count; + while (yy->__valslen <= yy->__val - yy->__vals) + { + long offset= yy->__val - yy->__vals; + yy->__valslen *= 2; + yy->__vals= (YYSTYPE *)YY_REALLOC(yy, yy->__vals, sizeof(YYSTYPE) * yy->__valslen); + yy->__val= yy->__vals + offset; + } +} +YY_LOCAL(void) yyPop(yycontext *yy, char *text, int count) { yy->__val -= count; } +YY_LOCAL(void) yySet(yycontext *yy, char *text, int count) { yy->__val[count]= yy->__; } + +#endif /* YY_PART */ + +#define YYACCEPT yyAccept(yy, yythunkpos0) + +YY_RULE(int) yy_comment(yycontext *yy); /* 39 */ +YY_RULE(int) yy_space(yycontext *yy); /* 38 */ +YY_RULE(int) yy_braces(yycontext *yy); /* 37 */ +YY_RULE(int) yy_range(yycontext *yy); /* 36 */ +YY_RULE(int) yy_char(yycontext *yy); /* 35 */ +YY_RULE(int) yy_END(yycontext *yy); /* 34 */ +YY_RULE(int) yy_BEGIN(yycontext *yy); /* 33 */ +YY_RULE(int) yy_DOT(yycontext *yy); /* 32 */ +YY_RULE(int) yy_class(yycontext *yy); /* 31 */ +YY_RULE(int) yy_literal(yycontext *yy); /* 30 */ +YY_RULE(int) yy_CLOSE(yycontext *yy); /* 29 */ +YY_RULE(int) yy_OPEN(yycontext *yy); /* 28 */ +YY_RULE(int) yy_COLON(yycontext *yy); /* 27 */ +YY_RULE(int) yy_PLUS(yycontext *yy); /* 26 */ +YY_RULE(int) yy_STAR(yycontext *yy); /* 25 */ +YY_RULE(int) yy_QUESTION(yycontext *yy); /* 24 */ +YY_RULE(int) yy_primary(yycontext *yy); /* 23 */ +YY_RULE(int) yy_NOT(yycontext *yy); /* 22 */ +YY_RULE(int) yy_suffix(yycontext *yy); /* 21 */ +YY_RULE(int) yy_AND(yycontext *yy); /* 20 */ +YY_RULE(int) yy_AT(yycontext *yy); /* 19 */ +YY_RULE(int) yy_action(yycontext *yy); /* 18 */ +YY_RULE(int) yy_TILDE(yycontext *yy); /* 17 */ +YY_RULE(int) yy_prefix(yycontext *yy); /* 16 */ +YY_RULE(int) yy_error(yycontext *yy); /* 15 */ +YY_RULE(int) yy_BAR(yycontext *yy); /* 14 */ +YY_RULE(int) yy_sequence(yycontext *yy); /* 13 */ +YY_RULE(int) yy_SEMICOLON(yycontext *yy); /* 12 */ +YY_RULE(int) yy_expression(yycontext *yy); /* 11 */ +YY_RULE(int) yy_EQUAL(yycontext *yy); /* 10 */ +YY_RULE(int) yy_identifier(yycontext *yy); /* 9 */ +YY_RULE(int) yy_RPERCENT(yycontext *yy); /* 8 */ +YY_RULE(int) yy_end_of_line(yycontext *yy); /* 7 */ +YY_RULE(int) yy_end_of_file(yycontext *yy); /* 6 */ +YY_RULE(int) yy_trailer(yycontext *yy); /* 5 */ +YY_RULE(int) yy_definition(yycontext *yy); /* 4 */ +YY_RULE(int) yy_declaration(yycontext *yy); /* 3 */ +YY_RULE(int) yy__(yycontext *yy); /* 2 */ +YY_RULE(int) yy_grammar(yycontext *yy); /* 1 */ + +YY_ACTION(void) yy_1_end_of_line(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_1_end_of_line\n")); + { +#line 160 + ++lineNumber ; + } +#undef yythunkpos +#undef yypos +#undef yy +} +YY_ACTION(void) yy_1_action(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_1_action\n")); + { +#line 133 + actionLine= lineNumber ; + } +#undef yythunkpos +#undef yypos +#undef yy +} +YY_ACTION(void) yy_9_primary(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_9_primary\n")); + { +#line 113 + push(makePredicate("YY_END")); ; + } +#undef yythunkpos +#undef yypos +#undef yy +} +YY_ACTION(void) yy_8_primary(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_8_primary\n")); + { +#line 112 + push(makePredicate("YY_BEGIN")); ; + } +#undef yythunkpos +#undef yypos +#undef yy +} +YY_ACTION(void) yy_7_primary(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_7_primary\n")); + { +#line 111 + push(makeAction(actionLine, yytext)); ; + } +#undef yythunkpos +#undef yypos +#undef yy +} +YY_ACTION(void) yy_6_primary(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_6_primary\n")); + { +#line 110 + push(makeDot()); ; + } +#undef yythunkpos +#undef yypos +#undef yy +} +YY_ACTION(void) yy_5_primary(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_5_primary\n")); + { +#line 109 + push(makeClass(yytext)); ; + } +#undef yythunkpos +#undef yypos +#undef yy +} +YY_ACTION(void) yy_4_primary(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_4_primary\n")); + { +#line 108 + push(makeString(yytext)); ; + } +#undef yythunkpos +#undef yypos +#undef yy +} +YY_ACTION(void) yy_3_primary(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_3_primary\n")); + { +#line 106 + push(makeName(findRule(yytext))); ; + } +#undef yythunkpos +#undef yypos +#undef yy +} +YY_ACTION(void) yy_2_primary(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_2_primary\n")); + { +#line 105 + Node *name= makeName(findRule(yytext)); name->name.variable= pop(); push(name); ; + } +#undef yythunkpos +#undef yypos +#undef yy +} +YY_ACTION(void) yy_1_primary(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_1_primary\n")); + { +#line 104 + push(makeVariable(yytext)); ; + } +#undef yythunkpos +#undef yypos +#undef yy +} +YY_ACTION(void) yy_3_suffix(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_3_suffix\n")); + { +#line 101 + push(makePlus (pop())); ; + } +#undef yythunkpos +#undef yypos +#undef yy +} +YY_ACTION(void) yy_2_suffix(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_2_suffix\n")); + { +#line 100 + push(makeStar (pop())); ; + } +#undef yythunkpos +#undef yypos +#undef yy +} +YY_ACTION(void) yy_1_suffix(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_1_suffix\n")); + { +#line 99 + push(makeQuery(pop())); ; + } +#undef yythunkpos +#undef yypos +#undef yy +} +YY_ACTION(void) yy_4_prefix(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_4_prefix\n")); + { +#line 96 + push(makePeekNot(pop())); ; + } +#undef yythunkpos +#undef yypos +#undef yy +} +YY_ACTION(void) yy_3_prefix(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_3_prefix\n")); + { +#line 95 + push(makePeekFor(pop())); ; + } +#undef yythunkpos +#undef yypos +#undef yy +} +YY_ACTION(void) yy_2_prefix(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_2_prefix\n")); + { +#line 94 + push(makePredicate(yytext)); ; + } +#undef yythunkpos +#undef yypos +#undef yy +} +YY_ACTION(void) yy_1_prefix(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_1_prefix\n")); + { +#line 93 + push(makeInline(yytext)); ; + } +#undef yythunkpos +#undef yypos +#undef yy +} +YY_ACTION(void) yy_1_error(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_1_error\n")); + { +#line 90 + push(makeError(pop(), yytext)); ; + } +#undef yythunkpos +#undef yypos +#undef yy +} +YY_ACTION(void) yy_1_sequence(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_1_sequence\n")); + { +#line 87 + Node *f= pop(); push(Sequence_append(pop(), f)); ; + } +#undef yythunkpos +#undef yypos +#undef yy +} +YY_ACTION(void) yy_1_expression(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_1_expression\n")); + { +#line 84 + Node *f= pop(); push(Alternate_append(pop(), f)); ; + } +#undef yythunkpos +#undef yypos +#undef yy +} +YY_ACTION(void) yy_2_definition(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_2_definition\n")); + { +#line 81 + Node *e= pop(); Rule_setExpression(pop(), e); ; + } +#undef yythunkpos +#undef yypos +#undef yy +} +YY_ACTION(void) yy_1_definition(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_1_definition\n")); + { +#line 79 + if (push(beginRule(findRule(yytext)))->rule.expression) + fprintf(stderr, "rule '%s' redefined\n", yytext); ; + } +#undef yythunkpos +#undef yypos +#undef yy +} +YY_ACTION(void) yy_2_trailer(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_2_trailer\n")); + { +#line 77 + makeTrailer(headerLine, yytext); ; + } +#undef yythunkpos +#undef yypos +#undef yy +} +YY_ACTION(void) yy_1_trailer(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_1_trailer\n")); + { +#line 76 + headerLine= lineNumber ; + } +#undef yythunkpos +#undef yypos +#undef yy +} +YY_ACTION(void) yy_2_declaration(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_2_declaration\n")); + { +#line 74 + makeHeader(headerLine, yytext); ; + } +#undef yythunkpos +#undef yypos +#undef yy +} +YY_ACTION(void) yy_1_declaration(yycontext *yy, char *yytext, int yyleng) +{ +#define __ yy->__ +#define yypos yy->__pos +#define yythunkpos yy->__thunkpos + yyprintf((stderr, "do yy_1_declaration\n")); + { +#line 72 + headerLine= lineNumber; ; + } +#undef yythunkpos +#undef yypos +#undef yy +} + +YY_RULE(int) yy_comment(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "comment")); if (!yymatchChar(yy, '#')) goto l1; + l2:; + { int yypos3= yy->__pos, yythunkpos3= yy->__thunkpos; + { int yypos4= yy->__pos, yythunkpos4= yy->__thunkpos; if (!yy_end_of_line(yy)) goto l4; goto l3; + l4:; yy->__pos= yypos4; yy->__thunkpos= yythunkpos4; + } if (!yymatchDot(yy)) goto l3; goto l2; + l3:; yy->__pos= yypos3; yy->__thunkpos= yythunkpos3; + } if (!yy_end_of_line(yy)) goto l1; + yyprintf((stderr, " ok %s @ %s\n", "comment", yy->__buf+yy->__pos)); + return 1; + l1:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "comment", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_space(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "space")); + { int yypos6= yy->__pos, yythunkpos6= yy->__thunkpos; if (!yymatchChar(yy, ' ')) goto l7; goto l6; + l7:; yy->__pos= yypos6; yy->__thunkpos= yythunkpos6; if (!yymatchChar(yy, '\t')) goto l8; goto l6; + l8:; yy->__pos= yypos6; yy->__thunkpos= yythunkpos6; if (!yy_end_of_line(yy)) goto l5; + } + l6:; + yyprintf((stderr, " ok %s @ %s\n", "space", yy->__buf+yy->__pos)); + return 1; + l5:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "space", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_braces(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "braces")); + { int yypos10= yy->__pos, yythunkpos10= yy->__thunkpos; if (!yymatchChar(yy, '{')) goto l11; + l12:; + { int yypos13= yy->__pos, yythunkpos13= yy->__thunkpos; if (!yy_braces(yy)) goto l13; goto l12; + l13:; yy->__pos= yypos13; yy->__thunkpos= yythunkpos13; + } if (!yymatchChar(yy, '}')) goto l11; goto l10; + l11:; yy->__pos= yypos10; yy->__thunkpos= yythunkpos10; + { int yypos14= yy->__pos, yythunkpos14= yy->__thunkpos; if (!yymatchChar(yy, '}')) goto l14; goto l9; + l14:; yy->__pos= yypos14; yy->__thunkpos= yythunkpos14; + } + { int yypos15= yy->__pos, yythunkpos15= yy->__thunkpos; if (!yy_end_of_line(yy)) goto l16; goto l15; + l16:; yy->__pos= yypos15; yy->__thunkpos= yythunkpos15; if (!yymatchDot(yy)) goto l9; + } + l15:; + } + l10:; + yyprintf((stderr, " ok %s @ %s\n", "braces", yy->__buf+yy->__pos)); + return 1; + l9:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "braces", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_range(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "range")); + { int yypos18= yy->__pos, yythunkpos18= yy->__thunkpos; if (!yy_char(yy)) goto l19; if (!yymatchChar(yy, '-')) goto l19; if (!yy_char(yy)) goto l19; goto l18; + l19:; yy->__pos= yypos18; yy->__thunkpos= yythunkpos18; if (!yy_char(yy)) goto l17; + } + l18:; + yyprintf((stderr, " ok %s @ %s\n", "range", yy->__buf+yy->__pos)); + return 1; + l17:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "range", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_char(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "char")); + { int yypos21= yy->__pos, yythunkpos21= yy->__thunkpos; if (!yymatchChar(yy, '\\')) goto l22; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\204\040\000\000\000\000\000\070\146\100\124\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l22; goto l21; + l22:; yy->__pos= yypos21; yy->__thunkpos= yythunkpos21; if (!yymatchChar(yy, '\\')) goto l23; if (!yymatchChar(yy, 'x')) goto l23; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\377\003\176\000\000\000\176\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l23; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\377\003\176\000\000\000\176\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l23; goto l21; + l23:; yy->__pos= yypos21; yy->__thunkpos= yythunkpos21; if (!yymatchChar(yy, '\\')) goto l24; if (!yymatchChar(yy, 'x')) goto l24; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\377\003\176\000\000\000\176\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l24; goto l21; + l24:; yy->__pos= yypos21; yy->__thunkpos= yythunkpos21; if (!yymatchChar(yy, '\\')) goto l25; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\017\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l25; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l25; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l25; goto l21; + l25:; yy->__pos= yypos21; yy->__thunkpos= yythunkpos21; if (!yymatchChar(yy, '\\')) goto l26; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l26; + { int yypos27= yy->__pos, yythunkpos27= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l27; goto l28; + l27:; yy->__pos= yypos27; yy->__thunkpos= yythunkpos27; + } + l28:; goto l21; + l26:; yy->__pos= yypos21; yy->__thunkpos= yythunkpos21; + { int yypos29= yy->__pos, yythunkpos29= yy->__thunkpos; if (!yymatchChar(yy, '\\')) goto l29; goto l20; + l29:; yy->__pos= yypos29; yy->__thunkpos= yythunkpos29; + } if (!yymatchDot(yy)) goto l20; + } + l21:; + yyprintf((stderr, " ok %s @ %s\n", "char", yy->__buf+yy->__pos)); + return 1; + l20:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "char", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_END(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "END")); if (!yymatchChar(yy, '>')) goto l30; if (!yy__(yy)) goto l30; + yyprintf((stderr, " ok %s @ %s\n", "END", yy->__buf+yy->__pos)); + return 1; + l30:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "END", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_BEGIN(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "BEGIN")); if (!yymatchChar(yy, '<')) goto l31; if (!yy__(yy)) goto l31; + yyprintf((stderr, " ok %s @ %s\n", "BEGIN", yy->__buf+yy->__pos)); + return 1; + l31:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "BEGIN", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_DOT(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "DOT")); if (!yymatchChar(yy, '.')) goto l32; if (!yy__(yy)) goto l32; + yyprintf((stderr, " ok %s @ %s\n", "DOT", yy->__buf+yy->__pos)); + return 1; + l32:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "DOT", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_class(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "class")); if (!yymatchChar(yy, '[')) goto l33; yyText(yy, yy->__begin, yy->__end); { +#define yytext yy->__text +#define yyleng yy->__textlen +if (!(YY_BEGIN)) goto l33; +#undef yytext +#undef yyleng + } + l34:; + { int yypos35= yy->__pos, yythunkpos35= yy->__thunkpos; + { int yypos36= yy->__pos, yythunkpos36= yy->__thunkpos; if (!yymatchChar(yy, ']')) goto l36; goto l35; + l36:; yy->__pos= yypos36; yy->__thunkpos= yythunkpos36; + } if (!yy_range(yy)) goto l35; goto l34; + l35:; yy->__pos= yypos35; yy->__thunkpos= yythunkpos35; + } yyText(yy, yy->__begin, yy->__end); { +#define yytext yy->__text +#define yyleng yy->__textlen +if (!(YY_END)) goto l33; +#undef yytext +#undef yyleng + } if (!yymatchChar(yy, ']')) goto l33; if (!yy__(yy)) goto l33; + yyprintf((stderr, " ok %s @ %s\n", "class", yy->__buf+yy->__pos)); + return 1; + l33:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "class", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_literal(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "literal")); + { int yypos38= yy->__pos, yythunkpos38= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l39; yyText(yy, yy->__begin, yy->__end); { +#define yytext yy->__text +#define yyleng yy->__textlen +if (!(YY_BEGIN)) goto l39; +#undef yytext +#undef yyleng + } + l40:; + { int yypos41= yy->__pos, yythunkpos41= yy->__thunkpos; + { int yypos42= yy->__pos, yythunkpos42= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l42; goto l41; + l42:; yy->__pos= yypos42; yy->__thunkpos= yythunkpos42; + } if (!yy_char(yy)) goto l41; goto l40; + l41:; yy->__pos= yypos41; yy->__thunkpos= yythunkpos41; + } yyText(yy, yy->__begin, yy->__end); { +#define yytext yy->__text +#define yyleng yy->__textlen +if (!(YY_END)) goto l39; +#undef yytext +#undef yyleng + } if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l39; if (!yy__(yy)) goto l39; goto l38; + l39:; yy->__pos= yypos38; yy->__thunkpos= yythunkpos38; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l37; yyText(yy, yy->__begin, yy->__end); { +#define yytext yy->__text +#define yyleng yy->__textlen +if (!(YY_BEGIN)) goto l37; +#undef yytext +#undef yyleng + } + l43:; + { int yypos44= yy->__pos, yythunkpos44= yy->__thunkpos; + { int yypos45= yy->__pos, yythunkpos45= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l45; goto l44; + l45:; yy->__pos= yypos45; yy->__thunkpos= yythunkpos45; + } if (!yy_char(yy)) goto l44; goto l43; + l44:; yy->__pos= yypos44; yy->__thunkpos= yythunkpos44; + } yyText(yy, yy->__begin, yy->__end); { +#define yytext yy->__text +#define yyleng yy->__textlen +if (!(YY_END)) goto l37; +#undef yytext +#undef yyleng + } if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l37; if (!yy__(yy)) goto l37; + } + l38:; + yyprintf((stderr, " ok %s @ %s\n", "literal", yy->__buf+yy->__pos)); + return 1; + l37:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "literal", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_CLOSE(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "CLOSE")); if (!yymatchChar(yy, ')')) goto l46; if (!yy__(yy)) goto l46; + yyprintf((stderr, " ok %s @ %s\n", "CLOSE", yy->__buf+yy->__pos)); + return 1; + l46:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "CLOSE", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_OPEN(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "OPEN")); if (!yymatchChar(yy, '(')) goto l47; if (!yy__(yy)) goto l47; + yyprintf((stderr, " ok %s @ %s\n", "OPEN", yy->__buf+yy->__pos)); + return 1; + l47:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "OPEN", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_COLON(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "COLON")); if (!yymatchChar(yy, ':')) goto l48; if (!yy__(yy)) goto l48; + yyprintf((stderr, " ok %s @ %s\n", "COLON", yy->__buf+yy->__pos)); + return 1; + l48:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "COLON", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_PLUS(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "PLUS")); if (!yymatchChar(yy, '+')) goto l49; if (!yy__(yy)) goto l49; + yyprintf((stderr, " ok %s @ %s\n", "PLUS", yy->__buf+yy->__pos)); + return 1; + l49:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "PLUS", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_STAR(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "STAR")); if (!yymatchChar(yy, '*')) goto l50; if (!yy__(yy)) goto l50; + yyprintf((stderr, " ok %s @ %s\n", "STAR", yy->__buf+yy->__pos)); + return 1; + l50:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "STAR", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_QUESTION(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "QUESTION")); if (!yymatchChar(yy, '?')) goto l51; if (!yy__(yy)) goto l51; + yyprintf((stderr, " ok %s @ %s\n", "QUESTION", yy->__buf+yy->__pos)); + return 1; + l51:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "QUESTION", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_primary(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "primary")); + { int yypos53= yy->__pos, yythunkpos53= yy->__thunkpos; if (!yy_identifier(yy)) goto l54; yyDo(yy, yy_1_primary, yy->__begin, yy->__end); if (!yy_COLON(yy)) goto l54; if (!yy_identifier(yy)) goto l54; + { int yypos55= yy->__pos, yythunkpos55= yy->__thunkpos; if (!yy_EQUAL(yy)) goto l55; goto l54; + l55:; yy->__pos= yypos55; yy->__thunkpos= yythunkpos55; + } yyDo(yy, yy_2_primary, yy->__begin, yy->__end); goto l53; + l54:; yy->__pos= yypos53; yy->__thunkpos= yythunkpos53; if (!yy_identifier(yy)) goto l56; + { int yypos57= yy->__pos, yythunkpos57= yy->__thunkpos; if (!yy_EQUAL(yy)) goto l57; goto l56; + l57:; yy->__pos= yypos57; yy->__thunkpos= yythunkpos57; + } yyDo(yy, yy_3_primary, yy->__begin, yy->__end); goto l53; + l56:; yy->__pos= yypos53; yy->__thunkpos= yythunkpos53; if (!yy_OPEN(yy)) goto l58; if (!yy_expression(yy)) goto l58; if (!yy_CLOSE(yy)) goto l58; goto l53; + l58:; yy->__pos= yypos53; yy->__thunkpos= yythunkpos53; if (!yy_literal(yy)) goto l59; yyDo(yy, yy_4_primary, yy->__begin, yy->__end); goto l53; + l59:; yy->__pos= yypos53; yy->__thunkpos= yythunkpos53; if (!yy_class(yy)) goto l60; yyDo(yy, yy_5_primary, yy->__begin, yy->__end); goto l53; + l60:; yy->__pos= yypos53; yy->__thunkpos= yythunkpos53; if (!yy_DOT(yy)) goto l61; yyDo(yy, yy_6_primary, yy->__begin, yy->__end); goto l53; + l61:; yy->__pos= yypos53; yy->__thunkpos= yythunkpos53; if (!yy_action(yy)) goto l62; yyDo(yy, yy_7_primary, yy->__begin, yy->__end); goto l53; + l62:; yy->__pos= yypos53; yy->__thunkpos= yythunkpos53; if (!yy_BEGIN(yy)) goto l63; yyDo(yy, yy_8_primary, yy->__begin, yy->__end); goto l53; + l63:; yy->__pos= yypos53; yy->__thunkpos= yythunkpos53; if (!yy_END(yy)) goto l52; yyDo(yy, yy_9_primary, yy->__begin, yy->__end); + } + l53:; + yyprintf((stderr, " ok %s @ %s\n", "primary", yy->__buf+yy->__pos)); + return 1; + l52:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "primary", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_NOT(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "NOT")); if (!yymatchChar(yy, '!')) goto l64; if (!yy__(yy)) goto l64; + yyprintf((stderr, " ok %s @ %s\n", "NOT", yy->__buf+yy->__pos)); + return 1; + l64:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "NOT", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_suffix(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "suffix")); if (!yy_primary(yy)) goto l65; + { int yypos66= yy->__pos, yythunkpos66= yy->__thunkpos; + { int yypos68= yy->__pos, yythunkpos68= yy->__thunkpos; if (!yy_QUESTION(yy)) goto l69; yyDo(yy, yy_1_suffix, yy->__begin, yy->__end); goto l68; + l69:; yy->__pos= yypos68; yy->__thunkpos= yythunkpos68; if (!yy_STAR(yy)) goto l70; yyDo(yy, yy_2_suffix, yy->__begin, yy->__end); goto l68; + l70:; yy->__pos= yypos68; yy->__thunkpos= yythunkpos68; if (!yy_PLUS(yy)) goto l66; yyDo(yy, yy_3_suffix, yy->__begin, yy->__end); + } + l68:; goto l67; + l66:; yy->__pos= yypos66; yy->__thunkpos= yythunkpos66; + } + l67:; + yyprintf((stderr, " ok %s @ %s\n", "suffix", yy->__buf+yy->__pos)); + return 1; + l65:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "suffix", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_AND(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "AND")); if (!yymatchChar(yy, '&')) goto l71; if (!yy__(yy)) goto l71; + yyprintf((stderr, " ok %s @ %s\n", "AND", yy->__buf+yy->__pos)); + return 1; + l71:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "AND", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_AT(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "AT")); if (!yymatchChar(yy, '@')) goto l72; if (!yy__(yy)) goto l72; + yyprintf((stderr, " ok %s @ %s\n", "AT", yy->__buf+yy->__pos)); + return 1; + l72:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "AT", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_action(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "action")); if (!yymatchChar(yy, '{')) goto l73; yyDo(yy, yy_1_action, yy->__begin, yy->__end); yyText(yy, yy->__begin, yy->__end); { +#define yytext yy->__text +#define yyleng yy->__textlen +if (!(YY_BEGIN)) goto l73; +#undef yytext +#undef yyleng + } + l74:; + { int yypos75= yy->__pos, yythunkpos75= yy->__thunkpos; if (!yy_braces(yy)) goto l75; goto l74; + l75:; yy->__pos= yypos75; yy->__thunkpos= yythunkpos75; + } yyText(yy, yy->__begin, yy->__end); { +#define yytext yy->__text +#define yyleng yy->__textlen +if (!(YY_END)) goto l73; +#undef yytext +#undef yyleng + } if (!yymatchChar(yy, '}')) goto l73; if (!yy__(yy)) goto l73; + yyprintf((stderr, " ok %s @ %s\n", "action", yy->__buf+yy->__pos)); + return 1; + l73:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "action", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_TILDE(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "TILDE")); if (!yymatchChar(yy, '~')) goto l76; if (!yy__(yy)) goto l76; + yyprintf((stderr, " ok %s @ %s\n", "TILDE", yy->__buf+yy->__pos)); + return 1; + l76:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "TILDE", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_prefix(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "prefix")); + { int yypos78= yy->__pos, yythunkpos78= yy->__thunkpos; if (!yy_AT(yy)) goto l79; if (!yy_action(yy)) goto l79; yyDo(yy, yy_1_prefix, yy->__begin, yy->__end); goto l78; + l79:; yy->__pos= yypos78; yy->__thunkpos= yythunkpos78; if (!yy_AND(yy)) goto l80; if (!yy_action(yy)) goto l80; yyDo(yy, yy_2_prefix, yy->__begin, yy->__end); goto l78; + l80:; yy->__pos= yypos78; yy->__thunkpos= yythunkpos78; if (!yy_AND(yy)) goto l81; if (!yy_suffix(yy)) goto l81; yyDo(yy, yy_3_prefix, yy->__begin, yy->__end); goto l78; + l81:; yy->__pos= yypos78; yy->__thunkpos= yythunkpos78; if (!yy_NOT(yy)) goto l82; if (!yy_suffix(yy)) goto l82; yyDo(yy, yy_4_prefix, yy->__begin, yy->__end); goto l78; + l82:; yy->__pos= yypos78; yy->__thunkpos= yythunkpos78; if (!yy_suffix(yy)) goto l77; + } + l78:; + yyprintf((stderr, " ok %s @ %s\n", "prefix", yy->__buf+yy->__pos)); + return 1; + l77:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "prefix", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_error(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "error")); if (!yy_prefix(yy)) goto l83; + { int yypos84= yy->__pos, yythunkpos84= yy->__thunkpos; if (!yy_TILDE(yy)) goto l84; if (!yy_action(yy)) goto l84; yyDo(yy, yy_1_error, yy->__begin, yy->__end); goto l85; + l84:; yy->__pos= yypos84; yy->__thunkpos= yythunkpos84; + } + l85:; + yyprintf((stderr, " ok %s @ %s\n", "error", yy->__buf+yy->__pos)); + return 1; + l83:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "error", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_BAR(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "BAR")); if (!yymatchChar(yy, '|')) goto l86; if (!yy__(yy)) goto l86; + yyprintf((stderr, " ok %s @ %s\n", "BAR", yy->__buf+yy->__pos)); + return 1; + l86:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "BAR", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_sequence(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "sequence")); if (!yy_error(yy)) goto l87; + l88:; + { int yypos89= yy->__pos, yythunkpos89= yy->__thunkpos; if (!yy_error(yy)) goto l89; yyDo(yy, yy_1_sequence, yy->__begin, yy->__end); goto l88; + l89:; yy->__pos= yypos89; yy->__thunkpos= yythunkpos89; + } + yyprintf((stderr, " ok %s @ %s\n", "sequence", yy->__buf+yy->__pos)); + return 1; + l87:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "sequence", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_SEMICOLON(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "SEMICOLON")); if (!yymatchChar(yy, ';')) goto l90; if (!yy__(yy)) goto l90; + yyprintf((stderr, " ok %s @ %s\n", "SEMICOLON", yy->__buf+yy->__pos)); + return 1; + l90:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "SEMICOLON", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_expression(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "expression")); if (!yy_sequence(yy)) goto l91; + l92:; + { int yypos93= yy->__pos, yythunkpos93= yy->__thunkpos; if (!yy_BAR(yy)) goto l93; if (!yy_sequence(yy)) goto l93; yyDo(yy, yy_1_expression, yy->__begin, yy->__end); goto l92; + l93:; yy->__pos= yypos93; yy->__thunkpos= yythunkpos93; + } + yyprintf((stderr, " ok %s @ %s\n", "expression", yy->__buf+yy->__pos)); + return 1; + l91:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "expression", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_EQUAL(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "EQUAL")); if (!yymatchChar(yy, '=')) goto l94; if (!yy__(yy)) goto l94; + yyprintf((stderr, " ok %s @ %s\n", "EQUAL", yy->__buf+yy->__pos)); + return 1; + l94:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "EQUAL", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_identifier(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "identifier")); yyText(yy, yy->__begin, yy->__end); { +#define yytext yy->__text +#define yyleng yy->__textlen +if (!(YY_BEGIN)) goto l95; +#undef yytext +#undef yyleng + } if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\040\000\000\376\377\377\207\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l95; + l96:; + { int yypos97= yy->__pos, yythunkpos97= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\040\377\003\376\377\377\207\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l97; goto l96; + l97:; yy->__pos= yypos97; yy->__thunkpos= yythunkpos97; + } yyText(yy, yy->__begin, yy->__end); { +#define yytext yy->__text +#define yyleng yy->__textlen +if (!(YY_END)) goto l95; +#undef yytext +#undef yyleng + } if (!yy__(yy)) goto l95; + yyprintf((stderr, " ok %s @ %s\n", "identifier", yy->__buf+yy->__pos)); + return 1; + l95:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "identifier", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_RPERCENT(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "RPERCENT")); if (!yymatchString(yy, "%}")) goto l98; if (!yy__(yy)) goto l98; + yyprintf((stderr, " ok %s @ %s\n", "RPERCENT", yy->__buf+yy->__pos)); + return 1; + l98:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "RPERCENT", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_end_of_line(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "end_of_line")); + { int yypos100= yy->__pos, yythunkpos100= yy->__thunkpos; if (!yymatchString(yy, "\r\n")) goto l101; goto l100; + l101:; yy->__pos= yypos100; yy->__thunkpos= yythunkpos100; if (!yymatchChar(yy, '\n')) goto l102; goto l100; + l102:; yy->__pos= yypos100; yy->__thunkpos= yythunkpos100; if (!yymatchChar(yy, '\r')) goto l99; + } + l100:; yyDo(yy, yy_1_end_of_line, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "end_of_line", yy->__buf+yy->__pos)); + return 1; + l99:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "end_of_line", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_end_of_file(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "end_of_file")); + { int yypos104= yy->__pos, yythunkpos104= yy->__thunkpos; if (!yymatchDot(yy)) goto l104; goto l103; + l104:; yy->__pos= yypos104; yy->__thunkpos= yythunkpos104; + } + yyprintf((stderr, " ok %s @ %s\n", "end_of_file", yy->__buf+yy->__pos)); + return 1; + l103:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "end_of_file", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_trailer(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "trailer")); if (!yymatchString(yy, "%%")) goto l105; yyDo(yy, yy_1_trailer, yy->__begin, yy->__end); yyText(yy, yy->__begin, yy->__end); { +#define yytext yy->__text +#define yyleng yy->__textlen +if (!(YY_BEGIN)) goto l105; +#undef yytext +#undef yyleng + } + l106:; + { int yypos107= yy->__pos, yythunkpos107= yy->__thunkpos; if (!yymatchDot(yy)) goto l107; goto l106; + l107:; yy->__pos= yypos107; yy->__thunkpos= yythunkpos107; + } yyText(yy, yy->__begin, yy->__end); { +#define yytext yy->__text +#define yyleng yy->__textlen +if (!(YY_END)) goto l105; +#undef yytext +#undef yyleng + } yyDo(yy, yy_2_trailer, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "trailer", yy->__buf+yy->__pos)); + return 1; + l105:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "trailer", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_definition(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "definition")); if (!yy_identifier(yy)) goto l108; yyDo(yy, yy_1_definition, yy->__begin, yy->__end); if (!yy_EQUAL(yy)) goto l108; if (!yy_expression(yy)) goto l108; yyDo(yy, yy_2_definition, yy->__begin, yy->__end); + { int yypos109= yy->__pos, yythunkpos109= yy->__thunkpos; if (!yy_SEMICOLON(yy)) goto l109; goto l110; + l109:; yy->__pos= yypos109; yy->__thunkpos= yythunkpos109; + } + l110:; + yyprintf((stderr, " ok %s @ %s\n", "definition", yy->__buf+yy->__pos)); + return 1; + l108:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "definition", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy_declaration(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "declaration")); if (!yymatchString(yy, "%{")) goto l111; yyDo(yy, yy_1_declaration, yy->__begin, yy->__end); yyText(yy, yy->__begin, yy->__end); { +#define yytext yy->__text +#define yyleng yy->__textlen +if (!(YY_BEGIN)) goto l111; +#undef yytext +#undef yyleng + } + l112:; + { int yypos113= yy->__pos, yythunkpos113= yy->__thunkpos; + { int yypos114= yy->__pos, yythunkpos114= yy->__thunkpos; if (!yymatchString(yy, "%}")) goto l114; goto l113; + l114:; yy->__pos= yypos114; yy->__thunkpos= yythunkpos114; + } + { int yypos115= yy->__pos, yythunkpos115= yy->__thunkpos; if (!yy_end_of_line(yy)) goto l116; goto l115; + l116:; yy->__pos= yypos115; yy->__thunkpos= yythunkpos115; if (!yymatchDot(yy)) goto l113; + } + l115:; goto l112; + l113:; yy->__pos= yypos113; yy->__thunkpos= yythunkpos113; + } yyText(yy, yy->__begin, yy->__end); { +#define yytext yy->__text +#define yyleng yy->__textlen +if (!(YY_END)) goto l111; +#undef yytext +#undef yyleng + } if (!yy_RPERCENT(yy)) goto l111; yyDo(yy, yy_2_declaration, yy->__begin, yy->__end); + yyprintf((stderr, " ok %s @ %s\n", "declaration", yy->__buf+yy->__pos)); + return 1; + l111:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "declaration", yy->__buf+yy->__pos)); + return 0; +} +YY_RULE(int) yy__(yycontext *yy) +{ + yyprintf((stderr, "%s\n", "_")); + l118:; + { int yypos119= yy->__pos, yythunkpos119= yy->__thunkpos; + { int yypos120= yy->__pos, yythunkpos120= yy->__thunkpos; if (!yy_space(yy)) goto l121; goto l120; + l121:; yy->__pos= yypos120; yy->__thunkpos= yythunkpos120; if (!yy_comment(yy)) goto l119; + } + l120:; goto l118; + l119:; yy->__pos= yypos119; yy->__thunkpos= yythunkpos119; + } + yyprintf((stderr, " ok %s @ %s\n", "_", yy->__buf+yy->__pos)); + return 1; +} +YY_RULE(int) yy_grammar(yycontext *yy) +{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; + yyprintf((stderr, "%s\n", "grammar")); if (!yy__(yy)) goto l122; + { int yypos125= yy->__pos, yythunkpos125= yy->__thunkpos; if (!yy_declaration(yy)) goto l126; goto l125; + l126:; yy->__pos= yypos125; yy->__thunkpos= yythunkpos125; if (!yy_definition(yy)) goto l122; + } + l125:; + l123:; + { int yypos124= yy->__pos, yythunkpos124= yy->__thunkpos; + { int yypos127= yy->__pos, yythunkpos127= yy->__thunkpos; if (!yy_declaration(yy)) goto l128; goto l127; + l128:; yy->__pos= yypos127; yy->__thunkpos= yythunkpos127; if (!yy_definition(yy)) goto l124; + } + l127:; goto l123; + l124:; yy->__pos= yypos124; yy->__thunkpos= yythunkpos124; + } + { int yypos129= yy->__pos, yythunkpos129= yy->__thunkpos; if (!yy_trailer(yy)) goto l129; goto l130; + l129:; yy->__pos= yypos129; yy->__thunkpos= yythunkpos129; + } + l130:; if (!yy_end_of_file(yy)) goto l122; + yyprintf((stderr, " ok %s @ %s\n", "grammar", yy->__buf+yy->__pos)); + return 1; + l122:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; + yyprintf((stderr, " fail %s @ %s\n", "grammar", yy->__buf+yy->__pos)); + return 0; +} + +#ifndef YY_PART + +typedef int (*yyrule)(yycontext *yy); + +YY_PARSE(int) YYPARSEFROM(YY_CTX_PARAM_ yyrule yystart) +{ + int yyok; + if (!yyctx->__buflen) + { + yyctx->__buflen= YY_BUFFER_SIZE; + yyctx->__buf= (char *)YY_MALLOC(yyctx, yyctx->__buflen); + yyctx->__textlen= YY_BUFFER_SIZE; + yyctx->__text= (char *)YY_MALLOC(yyctx, yyctx->__textlen); + yyctx->__thunkslen= YY_STACK_SIZE; + yyctx->__thunks= (yythunk *)YY_MALLOC(yyctx, sizeof(yythunk) * yyctx->__thunkslen); + yyctx->__valslen= YY_STACK_SIZE; + yyctx->__vals= (YYSTYPE *)YY_MALLOC(yyctx, sizeof(YYSTYPE) * yyctx->__valslen); + yyctx->__begin= yyctx->__end= yyctx->__pos= yyctx->__limit= yyctx->__thunkpos= 0; + } + yyctx->__begin= yyctx->__end= yyctx->__pos; + yyctx->__thunkpos= 0; + yyctx->__val= yyctx->__vals; + yyok= yystart(yyctx); + if (yyok) yyDone(yyctx); + yyCommit(yyctx); + return yyok; +} + +YY_PARSE(int) YYPARSE(YY_CTX_PARAM) +{ + return YYPARSEFROM(YY_CTX_ARG_ yy_grammar); +} + +YY_PARSE(yycontext *) YYRELEASE(yycontext *yyctx) +{ + if (yyctx->__buflen) + { + yyctx->__buflen= 0; + YY_FREE(yyctx, yyctx->__buf); + YY_FREE(yyctx, yyctx->__text); + YY_FREE(yyctx, yyctx->__thunks); + YY_FREE(yyctx, yyctx->__vals); + } + return yyctx; +} + +#endif +#line 163 "src/leg.leg" + + +void yyerror(char *message) +{ + fprintf(stderr, "%s:%d: %s", fileName, lineNumber, message); + if (yyctx->__text[0]) fprintf(stderr, " near token '%s'", yyctx->__text); + if (yyctx->__pos < yyctx->__limit || !feof(input)) + { + yyctx->__buf[yyctx->__limit]= '\0'; + fprintf(stderr, " before text \""); + while (yyctx->__pos < yyctx->__limit) + { + if ('\n' == yyctx->__buf[yyctx->__pos] || '\r' == yyctx->__buf[yyctx->__pos]) break; + fputc(yyctx->__buf[yyctx->__pos++], stderr); + } + if (yyctx->__pos == yyctx->__limit) + { + int c; + while (EOF != (c= fgetc(input)) && '\n' != c && '\r' != c) + fputc(c, stderr); + } + fputc('\"', stderr); + } + fprintf(stderr, "\n"); + exit(1); +} + +void makeHeader(int line, char *text) +{ + Header *header= (Header *)malloc(sizeof(Header)); + header->line= line; + header->text= strdup(text); + header->next= headers; + headers= header; +} + +void makeTrailer(int line, char *text) +{ + trailerLine= line; + trailer= strdup(text); +} + +static void version(char *name) +{ + printf("%s version %d.%d.%d\n", name, PEG_MAJOR, PEG_MINOR, PEG_LEVEL); +} + +static void usage(char *name) +{ + version(name); + fprintf(stderr, "usage: %s [