mirror of
https://github.com/kemko/liquid.git
synced 2026-01-02 08:15:41 +03:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c6bc2b2a3 | ||
|
|
56d1913b37 | ||
|
|
2f6b67798e | ||
|
|
82c222ef0f | ||
|
|
2baee3de3e | ||
|
|
a96cfd1297 | ||
|
|
cf765ebed3 | ||
|
|
8d234098aa |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -6,3 +6,5 @@ pkg
|
||||
.rvmrc
|
||||
*.o
|
||||
*.bundle
|
||||
ext/liquid/Makefile
|
||||
|
||||
|
||||
12
Rakefile
12
Rakefile
@@ -9,11 +9,11 @@ require 'rubygems/package_task'
|
||||
|
||||
task :default => [:compile, :test]
|
||||
|
||||
task :ragel do
|
||||
sh "find . -name '*.rl' | xargs ragel -C -G2"
|
||||
task :gen do
|
||||
sh "leg -oext/liquid/liquid_context.c ext/liquid/liquid_context.leg"
|
||||
end
|
||||
|
||||
task :compile => [:ragel, :liquid_ext]
|
||||
task :compile => [:gen, :liquid_ext]
|
||||
|
||||
extension = "liquid_ext"
|
||||
ext = "ext/liquid"
|
||||
@@ -21,7 +21,7 @@ ext_so = "#{ext}/#{extension}.#{RbConfig::CONFIG['DLEXT']}"
|
||||
ext_files = FileList[
|
||||
"#{ext}/*.c",
|
||||
"#{ext}/*.h",
|
||||
"#{ext}/*.rl",
|
||||
"#{ext}/*.leg",
|
||||
"#{ext}/extconf.rb",
|
||||
"#{ext}/Makefile",
|
||||
"lib"
|
||||
@@ -32,7 +32,7 @@ task "lib" do
|
||||
end
|
||||
|
||||
desc "Builds just the #{extension} extension"
|
||||
task extension.to_sym => [:ragel, "#{ext}/Makefile", ext_so ]
|
||||
task extension.to_sym => [:gen, "#{ext}/Makefile", ext_so ]
|
||||
|
||||
file "#{ext}/Makefile" => ["#{ext}/extconf.rb"] do
|
||||
Dir.chdir(ext) do ruby "extconf.rb" end
|
||||
@@ -45,7 +45,7 @@ file ext_so => ext_files do
|
||||
cp ext_so, "lib"
|
||||
end
|
||||
|
||||
Rake::TestTask.new(:test => [:ragel, 'liquid_ext']) do |t|
|
||||
Rake::TestTask.new(:test => [:gen, 'liquid_ext']) do |t|
|
||||
t.libs << '.' << 'lib' << 'test'
|
||||
t.test_files = FileList['test/liquid/**/*_test.rb']
|
||||
t.verbose = false
|
||||
|
||||
@@ -1,213 +0,0 @@
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
# V=0 quiet, V=1 verbose. other values don't work.
|
||||
V = 0
|
||||
Q1 = $(V:1=)
|
||||
Q = $(Q1:0=@)
|
||||
n=$(NULLCMD)
|
||||
ECHO1 = $(V:1=@$n)
|
||||
ECHO = $(ECHO1:0=@echo)
|
||||
|
||||
#### Start of system configuration section. ####
|
||||
|
||||
srcdir = .
|
||||
topdir = /Users/tobi/.rbenv/versions/1.9.3-p194-perf/include/ruby-1.9.1
|
||||
hdrdir = /Users/tobi/.rbenv/versions/1.9.3-p194-perf/include/ruby-1.9.1
|
||||
arch_hdrdir = /Users/tobi/.rbenv/versions/1.9.3-p194-perf/include/ruby-1.9.1/$(arch)
|
||||
VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
|
||||
prefix = $(DESTDIR)/Users/tobi/.rbenv/versions/1.9.3-p194-perf
|
||||
exec_prefix = $(prefix)
|
||||
rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
|
||||
bindir = $(exec_prefix)/bin
|
||||
sbindir = $(exec_prefix)/sbin
|
||||
libexecdir = $(exec_prefix)/libexec
|
||||
datarootdir = $(prefix)/share
|
||||
datadir = $(datarootdir)
|
||||
sysconfdir = $(prefix)/etc
|
||||
sharedstatedir = $(prefix)/com
|
||||
localstatedir = $(prefix)/var
|
||||
includedir = $(prefix)/include
|
||||
oldincludedir = $(DESTDIR)/usr/include
|
||||
docdir = $(datarootdir)/doc/$(PACKAGE)
|
||||
infodir = $(datarootdir)/info
|
||||
htmldir = $(docdir)
|
||||
dvidir = $(docdir)
|
||||
pdfdir = $(docdir)
|
||||
psdir = $(docdir)
|
||||
libdir = $(exec_prefix)/lib
|
||||
localedir = $(datarootdir)/locale
|
||||
mandir = $(datarootdir)/man
|
||||
ridir = $(datarootdir)/$(RI_BASE_NAME)
|
||||
sitedir = $(rubylibprefix)/site_ruby
|
||||
vendordir = $(rubylibprefix)/vendor_ruby
|
||||
rubyhdrdir = $(includedir)/$(RUBY_BASE_NAME)-$(ruby_version)
|
||||
sitehdrdir = $(rubyhdrdir)/site_ruby
|
||||
vendorhdrdir = $(rubyhdrdir)/vendor_ruby
|
||||
rubylibdir = $(rubylibprefix)/$(ruby_version)
|
||||
archdir = $(rubylibdir)/$(arch)
|
||||
sitelibdir = $(sitedir)/$(ruby_version)
|
||||
sitearchdir = $(sitelibdir)/$(sitearch)
|
||||
vendorlibdir = $(vendordir)/$(ruby_version)
|
||||
vendorarchdir = $(vendorlibdir)/$(sitearch)
|
||||
|
||||
NULLCMD = :
|
||||
|
||||
CC = /usr/bin/gcc-4.2
|
||||
CXX = g++
|
||||
LIBRUBY = $(LIBRUBY_A)
|
||||
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
|
||||
LIBRUBYARG_SHARED =
|
||||
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
|
||||
OUTFLAG = -o
|
||||
COUTFLAG = -o
|
||||
|
||||
RUBY_EXTCONF_H =
|
||||
cflags = $(optflags) $(debugflags) $(warnflags)
|
||||
optflags = -O3
|
||||
debugflags = -ggdb
|
||||
warnflags = -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration
|
||||
CFLAGS = -fno-common $(cflags) -pipe $(ARCH_FLAG)
|
||||
INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
|
||||
DEFS =
|
||||
CPPFLAGS = -I'/Users/tobi/.rbenv/versions/1.9.3-p194-perf/include' -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE $(DEFS) $(cppflags)
|
||||
CXXFLAGS = $(CFLAGS) $(cxxflags)
|
||||
ldflags = -L. -L'/Users/tobi/.rbenv/versions/1.9.3-p194-perf/lib' -L/usr/local/lib
|
||||
dldflags = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace
|
||||
ARCH_FLAG =
|
||||
DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
|
||||
LDSHARED = $(CC) -dynamic -bundle
|
||||
LDSHAREDXX = $(CXX) -dynamic -bundle
|
||||
AR = ar
|
||||
EXEEXT =
|
||||
|
||||
RUBY_BASE_NAME = ruby
|
||||
RUBY_INSTALL_NAME = ruby
|
||||
RUBY_SO_NAME = ruby
|
||||
arch = x86_64-darwin12.0.0
|
||||
sitearch = $(arch)
|
||||
ruby_version = 1.9.1
|
||||
ruby = /Users/tobi/.rbenv/versions/1.9.3-p194-perf/bin/ruby
|
||||
RUBY = $(ruby)
|
||||
RM = rm -f
|
||||
RM_RF = $(RUBY) -run -e rm -- -rf
|
||||
RMDIRS = rmdir -p
|
||||
MAKEDIRS = mkdir -p
|
||||
INSTALL = /usr/bin/install -c
|
||||
INSTALL_PROG = $(INSTALL) -m 0755
|
||||
INSTALL_DATA = $(INSTALL) -m 644
|
||||
COPY = cp
|
||||
|
||||
#### End of system configuration section. ####
|
||||
|
||||
preload =
|
||||
|
||||
libpath = . $(libdir)
|
||||
LIBPATH = -L. -L$(libdir)
|
||||
DEFFILE =
|
||||
|
||||
CLEANFILES = mkmf.log
|
||||
DISTCLEANFILES =
|
||||
DISTCLEANDIRS =
|
||||
|
||||
extout =
|
||||
extout_prefix =
|
||||
target_prefix =
|
||||
LOCAL_LIBS =
|
||||
LIBS = -lc -lpthread -ldl -lobjc
|
||||
SRCS = liquid_ext.c
|
||||
OBJS = liquid_ext.o
|
||||
TARGET = liquid_ext
|
||||
DLLIB = $(TARGET).bundle
|
||||
EXTSTATIC =
|
||||
STATIC_LIB =
|
||||
|
||||
BINDIR = $(bindir)
|
||||
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
|
||||
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
|
||||
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
|
||||
HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
|
||||
ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
|
||||
|
||||
TARGET_SO = $(DLLIB)
|
||||
CLEANLIBS = $(TARGET).bundle
|
||||
CLEANOBJS = *.o *.bak
|
||||
|
||||
all: $(DLLIB)
|
||||
static: $(STATIC_LIB)
|
||||
.PHONY: all install static install-so install-rb
|
||||
.PHONY: clean clean-so clean-rb
|
||||
|
||||
clean-rb-default::
|
||||
clean-rb::
|
||||
clean-so::
|
||||
clean: clean-so clean-rb-default clean-rb
|
||||
@-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
|
||||
|
||||
distclean-rb-default::
|
||||
distclean-rb::
|
||||
distclean-so::
|
||||
distclean: clean distclean-so distclean-rb-default distclean-rb
|
||||
@-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
|
||||
@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
|
||||
@-$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
|
||||
|
||||
realclean: distclean
|
||||
install: install-so install-rb
|
||||
|
||||
install-so: $(RUBYARCHDIR)
|
||||
install-so: $(RUBYARCHDIR)/$(DLLIB)
|
||||
$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
|
||||
@-$(MAKEDIRS) $(@D)
|
||||
$(INSTALL_PROG) $(DLLIB) $(@D)
|
||||
install-rb: pre-install-rb install-rb-default
|
||||
install-rb-default: pre-install-rb-default
|
||||
pre-install-rb: Makefile
|
||||
pre-install-rb-default: Makefile
|
||||
pre-install-rb-default:
|
||||
$(ECHO) installing default liquid_ext libraries
|
||||
$(RUBYARCHDIR):
|
||||
$(Q) $(MAKEDIRS) $@
|
||||
|
||||
site-install: site-install-so site-install-rb
|
||||
site-install-so: install-so
|
||||
site-install-rb: install-rb
|
||||
|
||||
.SUFFIXES: .c .m .cc .mm .cxx .cpp .C .o
|
||||
|
||||
.cc.o:
|
||||
$(ECHO) compiling $(<)
|
||||
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
||||
|
||||
.mm.o:
|
||||
$(ECHO) compiling $(<)
|
||||
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
||||
|
||||
.cxx.o:
|
||||
$(ECHO) compiling $(<)
|
||||
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
||||
|
||||
.cpp.o:
|
||||
$(ECHO) compiling $(<)
|
||||
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
||||
|
||||
.C.o:
|
||||
$(ECHO) compiling $(<)
|
||||
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
|
||||
|
||||
.c.o:
|
||||
$(ECHO) compiling $(<)
|
||||
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
|
||||
|
||||
.m.o:
|
||||
$(ECHO) compiling $(<)
|
||||
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
|
||||
|
||||
$(DLLIB): $(OBJS) Makefile
|
||||
$(ECHO) linking shared-object $(DLLIB)
|
||||
@-$(RM) $(@)
|
||||
$(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
|
||||
|
||||
|
||||
|
||||
$(OBJS): $(hdrdir)/ruby.h $(hdrdir)/ruby/defines.h $(arch_hdrdir)/ruby/config.h
|
||||
764
ext/liquid/liquid_context.c
Normal file
764
ext/liquid/liquid_context.c
Normal file
@@ -0,0 +1,764 @@
|
||||
/* A recursive-descent parser generated by peg 0.1.9 */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#define YYRULECOUNT 14
|
||||
|
||||
//uncomment to get more debug instrumentation
|
||||
//
|
||||
//#define YY_DEBUG
|
||||
|
||||
#include <ruby.h>
|
||||
|
||||
#define EMIT(sym, data) \
|
||||
rb_ary_push(ctx->rb_tokens, rb_ary_new3(2, ID2SYM(rb_intern(sym)), data));
|
||||
|
||||
#define yy_rb_str rb_str_new(yytext, yyleng)
|
||||
|
||||
#define YYSTYPE VALUE
|
||||
#define YY_CTX_LOCAL
|
||||
#define YY_CTX_MEMBERS VALUE rb_tokens; char *p; int p_len;
|
||||
|
||||
#define YY_INPUT(buf, result, max_size) { \
|
||||
result = ctx->p_len; \
|
||||
if (result>0 || EOF == ctx->p[0]) { \
|
||||
if (max_size < result) { result = max_size; } \
|
||||
strncpy(buf, ctx->p, result); \
|
||||
buf[result] = '\0'; \
|
||||
yyprintf((stderr, "\nREFILLING %d chars now:<%s>", result, buf)); \
|
||||
ctx->p += result; ctx->p_len -= result; \
|
||||
yyprintf((stderr, "\nREFILLING DONE size left: %d <%s>", ctx->p_len, ctx->p)); \
|
||||
} \
|
||||
}
|
||||
|
||||
#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 YY_INPUT
|
||||
#define YY_INPUT(buf, result, max_size) \
|
||||
{ \
|
||||
int yyc= getchar(); \
|
||||
result= (EOF == yyc) ? 0 : (*(buf)= yyc, 1); \
|
||||
yyprintf((stderr, "<%c>", yyc)); \
|
||||
}
|
||||
#endif
|
||||
#ifndef YY_BEGIN
|
||||
#define YY_BEGIN ( ctx->begin= ctx->pos, 1)
|
||||
#endif
|
||||
#ifndef YY_END
|
||||
#define YY_END ( ctx->end= ctx->pos, 1)
|
||||
#endif
|
||||
#ifdef YY_DEBUG
|
||||
# define yyprintf(args) fprintf args
|
||||
#else
|
||||
# define yyprintf(args)
|
||||
#endif
|
||||
#ifndef YYSTYPE
|
||||
#define YYSTYPE int
|
||||
#endif
|
||||
|
||||
#ifndef YY_PART
|
||||
|
||||
typedef struct _yycontext yycontext;
|
||||
typedef void (*yyaction)(yycontext *ctx, 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 yy;
|
||||
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
|
||||
#else
|
||||
#define YY_CTX_PARAM_
|
||||
#define YY_CTX_PARAM
|
||||
#define YY_CTX_ARG_
|
||||
#define YY_CTX_ARG
|
||||
yycontext yyctx0;
|
||||
yycontext *yyctx= &yyctx0;
|
||||
#endif
|
||||
|
||||
YY_LOCAL(int) yyrefill(yycontext *ctx)
|
||||
{
|
||||
int yyn;
|
||||
while (ctx->buflen - ctx->pos < 512)
|
||||
{
|
||||
ctx->buflen *= 2;
|
||||
ctx->buf= (char *)realloc(ctx->buf, ctx->buflen);
|
||||
}
|
||||
YY_INPUT((ctx->buf + ctx->pos), yyn, (ctx->buflen - ctx->pos));
|
||||
if (!yyn) return 0;
|
||||
ctx->limit += yyn;
|
||||
return 1;
|
||||
}
|
||||
|
||||
YY_LOCAL(int) yymatchDot(yycontext *ctx)
|
||||
{
|
||||
if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0;
|
||||
++ctx->pos;
|
||||
return 1;
|
||||
}
|
||||
|
||||
YY_LOCAL(int) yymatchChar(yycontext *ctx, int c)
|
||||
{
|
||||
if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0;
|
||||
if ((unsigned char)ctx->buf[ctx->pos] == c)
|
||||
{
|
||||
++ctx->pos;
|
||||
yyprintf((stderr, " ok yymatchChar(ctx, %c) @ %s\n", c, ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
}
|
||||
yyprintf((stderr, " fail yymatchChar(ctx, %c) @ %s\n", c, ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
|
||||
YY_LOCAL(int) yymatchString(yycontext *ctx, char *s)
|
||||
{
|
||||
int yysav= ctx->pos;
|
||||
while (*s)
|
||||
{
|
||||
if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0;
|
||||
if (ctx->buf[ctx->pos] != *s)
|
||||
{
|
||||
ctx->pos= yysav;
|
||||
return 0;
|
||||
}
|
||||
++s;
|
||||
++ctx->pos;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
YY_LOCAL(int) yymatchClass(yycontext *ctx, unsigned char *bits)
|
||||
{
|
||||
int c;
|
||||
if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0;
|
||||
c= (unsigned char)ctx->buf[ctx->pos];
|
||||
if (bits[c >> 3] & (1 << (c & 7)))
|
||||
{
|
||||
++ctx->pos;
|
||||
yyprintf((stderr, " ok yymatchClass @ %s\n", ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
}
|
||||
yyprintf((stderr, " fail yymatchClass @ %s\n", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
|
||||
YY_LOCAL(void) yyDo(yycontext *ctx, yyaction action, int begin, int end)
|
||||
{
|
||||
while (ctx->thunkpos >= ctx->thunkslen)
|
||||
{
|
||||
ctx->thunkslen *= 2;
|
||||
ctx->thunks= (yythunk *)realloc(ctx->thunks, sizeof(yythunk) * ctx->thunkslen);
|
||||
}
|
||||
ctx->thunks[ctx->thunkpos].begin= begin;
|
||||
ctx->thunks[ctx->thunkpos].end= end;
|
||||
ctx->thunks[ctx->thunkpos].action= action;
|
||||
++ctx->thunkpos;
|
||||
}
|
||||
|
||||
YY_LOCAL(int) yyText(yycontext *ctx, int begin, int end)
|
||||
{
|
||||
int yyleng= end - begin;
|
||||
if (yyleng <= 0)
|
||||
yyleng= 0;
|
||||
else
|
||||
{
|
||||
while (ctx->textlen < (yyleng + 1))
|
||||
{
|
||||
ctx->textlen *= 2;
|
||||
ctx->text= (char *)realloc(ctx->text, ctx->textlen);
|
||||
}
|
||||
memcpy(ctx->text, ctx->buf + begin, yyleng);
|
||||
}
|
||||
ctx->text[yyleng]= '\0';
|
||||
return yyleng;
|
||||
}
|
||||
|
||||
YY_LOCAL(void) yyDone(yycontext *ctx)
|
||||
{
|
||||
int pos;
|
||||
for (pos= 0; pos < ctx->thunkpos; ++pos)
|
||||
{
|
||||
yythunk *thunk= &ctx->thunks[pos];
|
||||
int yyleng= thunk->end ? yyText(ctx, thunk->begin, thunk->end) : thunk->begin;
|
||||
yyprintf((stderr, "DO [%d] %p %s\n", pos, thunk->action, ctx->text));
|
||||
thunk->action(ctx, ctx->text, yyleng);
|
||||
}
|
||||
ctx->thunkpos= 0;
|
||||
}
|
||||
|
||||
YY_LOCAL(void) yyCommit(yycontext *ctx)
|
||||
{
|
||||
if ((ctx->limit -= ctx->pos))
|
||||
{
|
||||
memmove(ctx->buf, ctx->buf + ctx->pos, ctx->limit);
|
||||
}
|
||||
ctx->begin -= ctx->pos;
|
||||
ctx->end -= ctx->pos;
|
||||
ctx->pos= ctx->thunkpos= 0;
|
||||
}
|
||||
|
||||
YY_LOCAL(int) yyAccept(yycontext *ctx, int tp0)
|
||||
{
|
||||
if (tp0)
|
||||
{
|
||||
fprintf(stderr, "accept denied at %d\n", tp0);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
yyDone(ctx);
|
||||
yyCommit(ctx);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
YY_LOCAL(void) yyPush(yycontext *ctx, char *text, int count) { ctx->val += count; }
|
||||
YY_LOCAL(void) yyPop(yycontext *ctx, char *text, int count) { ctx->val -= count; }
|
||||
YY_LOCAL(void) yySet(yycontext *ctx, char *text, int count) { ctx->val[count]= ctx->yy; }
|
||||
|
||||
#endif /* YY_PART */
|
||||
|
||||
#define YYACCEPT yyAccept(ctx, yythunkpos0)
|
||||
|
||||
YY_RULE(int) yy_digit(yycontext *ctx); /* 14 */
|
||||
YY_RULE(int) yy_float(yycontext *ctx); /* 13 */
|
||||
YY_RULE(int) yy_integer(yycontext *ctx); /* 12 */
|
||||
YY_RULE(int) yy_rangelet(yycontext *ctx); /* 11 */
|
||||
YY_RULE(int) yy_identifier(yycontext *ctx); /* 10 */
|
||||
YY_RULE(int) yy_accessors(yycontext *ctx); /* 9 */
|
||||
YY_RULE(int) yy_numeric(yycontext *ctx); /* 8 */
|
||||
YY_RULE(int) yy_string(yycontext *ctx); /* 7 */
|
||||
YY_RULE(int) yy_const(yycontext *ctx); /* 6 */
|
||||
YY_RULE(int) yy_hash(yycontext *ctx); /* 5 */
|
||||
YY_RULE(int) yy_range(yycontext *ctx); /* 4 */
|
||||
YY_RULE(int) yy_entity(yycontext *ctx); /* 3 */
|
||||
YY_RULE(int) yy_primary(yycontext *ctx); /* 2 */
|
||||
YY_RULE(int) yy_grammar(yycontext *ctx); /* 1 */
|
||||
|
||||
YY_ACTION(void) yy_4_const(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_4_const\n"));
|
||||
yy = Qnil; ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_3_const(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_3_const\n"));
|
||||
yy = Qnil; ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_2_const(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_2_const\n"));
|
||||
yy = Qfalse; ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_1_const(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_1_const\n"));
|
||||
yy = Qtrue; ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_1_integer(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_1_integer\n"));
|
||||
yy = rb_funcall(rb_cObject, rb_intern("Integer"), 1, yy_rb_str); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_1_float(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_1_float\n"));
|
||||
yy = rb_funcall(rb_cObject, rb_intern("Float"), 1, yy_rb_str); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_2_string(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_2_string\n"));
|
||||
yy = yy_rb_str; ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_1_string(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_1_string\n"));
|
||||
yy = yy_rb_str; ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_1_range(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_1_range\n"));
|
||||
EMIT("range", Qnil); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_1_rangelet(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define var ctx->val[-1]
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_1_rangelet\n"));
|
||||
EMIT("id", var); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
#undef var
|
||||
}
|
||||
YY_ACTION(void) yy_1_entity(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_1_entity\n"));
|
||||
EMIT("id", yy_rb_str); EMIT("lookup", Qnil); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_5_accessors(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_5_accessors\n"));
|
||||
EMIT("id", yy_rb_str); EMIT("call", Qnil); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_4_accessors(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_4_accessors\n"));
|
||||
EMIT("buildin", rb_str_new2("size")); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_3_accessors(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_3_accessors\n"));
|
||||
EMIT("buildin", rb_str_new2("last")); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_2_accessors(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_2_accessors\n"));
|
||||
EMIT("buildin", rb_str_new2("first")); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_1_accessors(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_1_accessors\n"));
|
||||
EMIT("call", Qnil); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_3_primary(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define var ctx->val[-1]
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_3_primary\n"));
|
||||
EMIT("id", var); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
#undef var
|
||||
}
|
||||
YY_ACTION(void) yy_2_primary(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define var ctx->val[-1]
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_2_primary\n"));
|
||||
EMIT("id", var); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
#undef var
|
||||
}
|
||||
YY_ACTION(void) yy_1_primary(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define var ctx->val[-1]
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_1_primary\n"));
|
||||
EMIT("id", var); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
#undef var
|
||||
}
|
||||
YY_ACTION(void) yy_1_grammar(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_1_grammar\n"));
|
||||
EMIT("lookup", Qnil); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
|
||||
YY_RULE(int) yy_digit(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
|
||||
yyprintf((stderr, "%s\n", "digit")); if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\000\000\377\003\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 l1;
|
||||
yyprintf((stderr, " ok %s @ %s\n", "digit", ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
l1:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "digit", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
YY_RULE(int) yy_float(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
|
||||
yyprintf((stderr, "%s\n", "float")); yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l2;
|
||||
{ int yypos3= ctx->pos, yythunkpos3= ctx->thunkpos; if (!yymatchChar(ctx, '-')) goto l3; goto l4;
|
||||
l3:; ctx->pos= yypos3; ctx->thunkpos= yythunkpos3;
|
||||
}
|
||||
l4:; if (!yy_digit(ctx)) goto l2; if (!yymatchChar(ctx, '.')) goto l2; if (!yy_digit(ctx)) goto l2;
|
||||
l5:;
|
||||
{ int yypos6= ctx->pos, yythunkpos6= ctx->thunkpos; if (!yy_digit(ctx)) goto l6; goto l5;
|
||||
l6:; ctx->pos= yypos6; ctx->thunkpos= yythunkpos6;
|
||||
} yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l2; yyDo(ctx, yy_1_float, ctx->begin, ctx->end);
|
||||
yyprintf((stderr, " ok %s @ %s\n", "float", ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
l2:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "float", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
YY_RULE(int) yy_integer(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
|
||||
yyprintf((stderr, "%s\n", "integer")); yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l7;
|
||||
{ int yypos8= ctx->pos, yythunkpos8= ctx->thunkpos; if (!yymatchChar(ctx, '-')) goto l8; goto l9;
|
||||
l8:; ctx->pos= yypos8; ctx->thunkpos= yythunkpos8;
|
||||
}
|
||||
l9:; if (!yy_digit(ctx)) goto l7;
|
||||
l10:;
|
||||
{ int yypos11= ctx->pos, yythunkpos11= ctx->thunkpos; if (!yy_digit(ctx)) goto l11; goto l10;
|
||||
l11:; ctx->pos= yypos11; ctx->thunkpos= yythunkpos11;
|
||||
} yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l7; yyDo(ctx, yy_1_integer, ctx->begin, ctx->end);
|
||||
yyprintf((stderr, " ok %s @ %s\n", "integer", ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
l7:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "integer", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
YY_RULE(int) yy_rangelet(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; yyDo(ctx, yyPush, 1, 0);
|
||||
yyprintf((stderr, "%s\n", "rangelet"));
|
||||
{ int yypos13= ctx->pos, yythunkpos13= ctx->thunkpos; if (!yy_integer(ctx)) goto l14; yyDo(ctx, yySet, -1, 0); yyDo(ctx, yy_1_rangelet, ctx->begin, ctx->end); goto l13;
|
||||
l14:; ctx->pos= yypos13; ctx->thunkpos= yythunkpos13; if (!yy_entity(ctx)) goto l12;
|
||||
}
|
||||
l13:;
|
||||
yyprintf((stderr, " ok %s @ %s\n", "rangelet", ctx->buf+ctx->pos)); yyDo(ctx, yyPop, 1, 0);
|
||||
return 1;
|
||||
l12:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "rangelet", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
YY_RULE(int) yy_identifier(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
|
||||
yyprintf((stderr, "%s\n", "identifier")); if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\000\000\000\000\376\377\377\007\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l15;
|
||||
l16:;
|
||||
{ int yypos17= ctx->pos, yythunkpos17= ctx->thunkpos; if (!yymatchClass(ctx, (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 l17; goto l16;
|
||||
l17:; ctx->pos= yypos17; ctx->thunkpos= yythunkpos17;
|
||||
}
|
||||
{ int yypos18= ctx->pos, yythunkpos18= ctx->thunkpos; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\002\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")) goto l18; goto l19;
|
||||
l18:; ctx->pos= yypos18; ctx->thunkpos= yythunkpos18;
|
||||
}
|
||||
l19:;
|
||||
yyprintf((stderr, " ok %s @ %s\n", "identifier", ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
l15:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "identifier", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
YY_RULE(int) yy_accessors(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
|
||||
yyprintf((stderr, "%s\n", "accessors"));
|
||||
{ int yypos21= ctx->pos, yythunkpos21= ctx->thunkpos; if (!yy_hash(ctx)) goto l22; yyDo(ctx, yy_1_accessors, ctx->begin, ctx->end); goto l21;
|
||||
l22:; ctx->pos= yypos21; ctx->thunkpos= yythunkpos21; if (!yymatchString(ctx, ".first")) goto l23; yyDo(ctx, yy_2_accessors, ctx->begin, ctx->end); goto l21;
|
||||
l23:; ctx->pos= yypos21; ctx->thunkpos= yythunkpos21; if (!yymatchString(ctx, ".last")) goto l24; yyDo(ctx, yy_3_accessors, ctx->begin, ctx->end); goto l21;
|
||||
l24:; ctx->pos= yypos21; ctx->thunkpos= yythunkpos21; if (!yymatchString(ctx, ".size")) goto l25; yyDo(ctx, yy_4_accessors, ctx->begin, ctx->end); goto l21;
|
||||
l25:; ctx->pos= yypos21; ctx->thunkpos= yythunkpos21; if (!yymatchChar(ctx, '.')) goto l20; yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l20; if (!yy_identifier(ctx)) goto l20; yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l20; yyDo(ctx, yy_5_accessors, ctx->begin, ctx->end);
|
||||
}
|
||||
l21:;
|
||||
yyprintf((stderr, " ok %s @ %s\n", "accessors", ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
l20:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "accessors", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
YY_RULE(int) yy_numeric(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
|
||||
yyprintf((stderr, "%s\n", "numeric"));
|
||||
{ int yypos27= ctx->pos, yythunkpos27= ctx->thunkpos; if (!yy_float(ctx)) goto l28; goto l27;
|
||||
l28:; ctx->pos= yypos27; ctx->thunkpos= yythunkpos27; if (!yy_integer(ctx)) goto l26;
|
||||
}
|
||||
l27:;
|
||||
yyprintf((stderr, " ok %s @ %s\n", "numeric", ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
l26:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "numeric", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
YY_RULE(int) yy_string(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
|
||||
yyprintf((stderr, "%s\n", "string"));
|
||||
{ int yypos30= ctx->pos, yythunkpos30= ctx->thunkpos; if (!yymatchClass(ctx, (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 l31; yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l31;
|
||||
l32:;
|
||||
{ int yypos33= ctx->pos, yythunkpos33= ctx->thunkpos;
|
||||
{ int yypos34= ctx->pos, yythunkpos34= ctx->thunkpos; if (!yymatchClass(ctx, (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 l34; goto l33;
|
||||
l34:; ctx->pos= yypos34; ctx->thunkpos= yythunkpos34;
|
||||
} if (!yymatchDot(ctx)) goto l33; goto l32;
|
||||
l33:; ctx->pos= yypos33; ctx->thunkpos= yythunkpos33;
|
||||
} yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l31; if (!yymatchClass(ctx, (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 l31; yyDo(ctx, yy_1_string, ctx->begin, ctx->end); goto l30;
|
||||
l31:; ctx->pos= yypos30; ctx->thunkpos= yythunkpos30; if (!yymatchClass(ctx, (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 l29; yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l29;
|
||||
l35:;
|
||||
{ int yypos36= ctx->pos, yythunkpos36= ctx->thunkpos;
|
||||
{ int yypos37= ctx->pos, yythunkpos37= ctx->thunkpos; if (!yymatchClass(ctx, (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; goto l36;
|
||||
l37:; ctx->pos= yypos37; ctx->thunkpos= yythunkpos37;
|
||||
} if (!yymatchDot(ctx)) goto l36; goto l35;
|
||||
l36:; ctx->pos= yypos36; ctx->thunkpos= yythunkpos36;
|
||||
} yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l29; if (!yymatchClass(ctx, (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 l29; yyDo(ctx, yy_2_string, ctx->begin, ctx->end);
|
||||
}
|
||||
l30:;
|
||||
yyprintf((stderr, " ok %s @ %s\n", "string", ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
l29:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "string", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
YY_RULE(int) yy_const(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
|
||||
yyprintf((stderr, "%s\n", "const"));
|
||||
{ int yypos39= ctx->pos, yythunkpos39= ctx->thunkpos; if (!yymatchString(ctx, "true")) goto l40; yyDo(ctx, yy_1_const, ctx->begin, ctx->end); goto l39;
|
||||
l40:; ctx->pos= yypos39; ctx->thunkpos= yythunkpos39; if (!yymatchString(ctx, "false")) goto l41; yyDo(ctx, yy_2_const, ctx->begin, ctx->end); goto l39;
|
||||
l41:; ctx->pos= yypos39; ctx->thunkpos= yythunkpos39; if (!yymatchString(ctx, "nil")) goto l42; yyDo(ctx, yy_3_const, ctx->begin, ctx->end); goto l39;
|
||||
l42:; ctx->pos= yypos39; ctx->thunkpos= yythunkpos39; if (!yymatchString(ctx, "null")) goto l38; yyDo(ctx, yy_4_const, ctx->begin, ctx->end);
|
||||
}
|
||||
l39:;
|
||||
yyprintf((stderr, " ok %s @ %s\n", "const", ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
l38:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "const", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
YY_RULE(int) yy_hash(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
|
||||
yyprintf((stderr, "%s\n", "hash")); if (!yymatchChar(ctx, '[')) goto l43;
|
||||
{ int yypos44= ctx->pos, yythunkpos44= ctx->thunkpos; if (!yy_primary(ctx)) goto l45; goto l44;
|
||||
l45:; ctx->pos= yypos44; ctx->thunkpos= yythunkpos44; if (!yy_entity(ctx)) goto l43;
|
||||
}
|
||||
l44:; if (!yymatchChar(ctx, ']')) goto l43;
|
||||
yyprintf((stderr, " ok %s @ %s\n", "hash", ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
l43:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "hash", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
YY_RULE(int) yy_range(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
|
||||
yyprintf((stderr, "%s\n", "range")); if (!yymatchChar(ctx, '(')) goto l46; if (!yy_rangelet(ctx)) goto l46; if (!yymatchString(ctx, "..")) goto l46; if (!yy_rangelet(ctx)) goto l46; if (!yymatchChar(ctx, ')')) goto l46; yyDo(ctx, yy_1_range, ctx->begin, ctx->end);
|
||||
yyprintf((stderr, " ok %s @ %s\n", "range", ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
l46:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "range", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
YY_RULE(int) yy_entity(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
|
||||
yyprintf((stderr, "%s\n", "entity")); yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l47; if (!yy_identifier(ctx)) goto l47; yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l47; yyDo(ctx, yy_1_entity, ctx->begin, ctx->end);
|
||||
l48:;
|
||||
{ int yypos49= ctx->pos, yythunkpos49= ctx->thunkpos; if (!yy_accessors(ctx)) goto l49; goto l48;
|
||||
l49:; ctx->pos= yypos49; ctx->thunkpos= yythunkpos49;
|
||||
}
|
||||
yyprintf((stderr, " ok %s @ %s\n", "entity", ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
l47:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "entity", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
YY_RULE(int) yy_primary(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; yyDo(ctx, yyPush, 1, 0);
|
||||
yyprintf((stderr, "%s\n", "primary"));
|
||||
{ int yypos51= ctx->pos, yythunkpos51= ctx->thunkpos; if (!yy_const(ctx)) goto l52; yyDo(ctx, yySet, -1, 0); yyDo(ctx, yy_1_primary, ctx->begin, ctx->end); goto l51;
|
||||
l52:; ctx->pos= yypos51; ctx->thunkpos= yythunkpos51; if (!yy_string(ctx)) goto l53; yyDo(ctx, yySet, -1, 0); yyDo(ctx, yy_2_primary, ctx->begin, ctx->end); goto l51;
|
||||
l53:; ctx->pos= yypos51; ctx->thunkpos= yythunkpos51; if (!yy_numeric(ctx)) goto l50; yyDo(ctx, yySet, -1, 0); yyDo(ctx, yy_3_primary, ctx->begin, ctx->end);
|
||||
}
|
||||
l51:;
|
||||
yyprintf((stderr, " ok %s @ %s\n", "primary", ctx->buf+ctx->pos)); yyDo(ctx, yyPop, 1, 0);
|
||||
return 1;
|
||||
l50:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "primary", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
YY_RULE(int) yy_grammar(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
|
||||
yyprintf((stderr, "%s\n", "grammar"));
|
||||
{ int yypos55= ctx->pos, yythunkpos55= ctx->thunkpos; if (!yy_primary(ctx)) goto l56; goto l55;
|
||||
l56:; ctx->pos= yypos55; ctx->thunkpos= yythunkpos55; if (!yy_entity(ctx)) goto l57; goto l55;
|
||||
l57:; ctx->pos= yypos55; ctx->thunkpos= yythunkpos55; if (!yy_range(ctx)) goto l58; goto l55;
|
||||
l58:; ctx->pos= yypos55; ctx->thunkpos= yythunkpos55; if (!yy_hash(ctx)) goto l54; yyDo(ctx, yy_1_grammar, ctx->begin, ctx->end);
|
||||
}
|
||||
l55:;
|
||||
yyprintf((stderr, " ok %s @ %s\n", "grammar", ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
l54:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "grammar", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef YY_PART
|
||||
|
||||
typedef int (*yyrule)(yycontext *ctx);
|
||||
|
||||
YY_PARSE(int) YYPARSEFROM(YY_CTX_PARAM_ yyrule yystart)
|
||||
{
|
||||
int yyok;
|
||||
if (!yyctx->buflen)
|
||||
{
|
||||
yyctx->buflen= 1024;
|
||||
yyctx->buf= (char *)malloc(yyctx->buflen);
|
||||
yyctx->textlen= 1024;
|
||||
yyctx->text= (char *)malloc(yyctx->textlen);
|
||||
yyctx->thunkslen= 32;
|
||||
yyctx->thunks= (yythunk *)malloc(sizeof(yythunk) * yyctx->thunkslen);
|
||||
yyctx->valslen= 32;
|
||||
yyctx->vals= (YYSTYPE *)malloc(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);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
VALUE liquid_context_parse_impl(VALUE self, VALUE text) {
|
||||
char *p;
|
||||
int len;
|
||||
yycontext ctx;
|
||||
|
||||
memset(&ctx, 0, sizeof(yycontext));
|
||||
ctx.p = RSTRING_PTR(text);
|
||||
ctx.p_len = (int) RSTRING_LEN(text);
|
||||
ctx.rb_tokens = rb_ary_new();
|
||||
|
||||
yyparse(&ctx);
|
||||
|
||||
return ctx.rb_tokens;
|
||||
}
|
||||
98
ext/liquid/liquid_context.leg
Normal file
98
ext/liquid/liquid_context.leg
Normal file
@@ -0,0 +1,98 @@
|
||||
|
||||
%{
|
||||
//uncomment to get more debug instrumentation
|
||||
//
|
||||
//#define YY_DEBUG
|
||||
|
||||
#include <ruby.h>
|
||||
|
||||
#define EMIT(sym, data) \
|
||||
rb_ary_push(ctx->rb_tokens, rb_ary_new3(2, ID2SYM(rb_intern(sym)), data));
|
||||
|
||||
#define yy_rb_str rb_str_new(yytext, yyleng)
|
||||
|
||||
#define YYSTYPE VALUE
|
||||
#define YY_CTX_LOCAL
|
||||
#define YY_CTX_MEMBERS VALUE rb_tokens; char *p; int p_len;
|
||||
|
||||
#define YY_INPUT(buf, result, max_size) { \
|
||||
result = ctx->p_len; \
|
||||
if (result>0 || EOF == ctx->p[0]) { \
|
||||
if (max_size < result) { result = max_size; } \
|
||||
strncpy(buf, ctx->p, result); \
|
||||
buf[result] = '\0'; \
|
||||
yyprintf((stderr, "\nREFILLING %d chars now:<%s>", result, buf)); \
|
||||
ctx->p += result; ctx->p_len -= result; \
|
||||
yyprintf((stderr, "\nREFILLING DONE size left: %d <%s>", ctx->p_len, ctx->p)); \
|
||||
} \
|
||||
}
|
||||
%}
|
||||
|
||||
grammar = primary
|
||||
| entity
|
||||
| range
|
||||
| hash { EMIT("lookup", Qnil); }
|
||||
;
|
||||
|
||||
hash = '[' (primary|entity) ']';
|
||||
|
||||
primary = var:const { EMIT("id", var); }
|
||||
| var:string { EMIT("id", var); }
|
||||
| var:numeric { EMIT("id", var); }
|
||||
;
|
||||
|
||||
accessors = hash { EMIT("call", Qnil); }
|
||||
| '.first' { EMIT("buildin", rb_str_new2("first")); }
|
||||
| '.last' { EMIT("buildin", rb_str_new2("last")); }
|
||||
| '.size' { EMIT("buildin", rb_str_new2("size")); }
|
||||
| '.' <identifier> { EMIT("id", yy_rb_str); EMIT("call", Qnil); }
|
||||
;
|
||||
|
||||
entity = <identifier> { EMIT("id", yy_rb_str); EMIT("lookup", Qnil); }
|
||||
accessors*
|
||||
;
|
||||
|
||||
rangelet = var:integer { EMIT("id", var); }
|
||||
| entity
|
||||
;
|
||||
|
||||
range = '(' rangelet '..' rangelet ')' { EMIT("range", Qnil); }
|
||||
|
||||
|
||||
string = ['] < ( !['] . )* > ['] { $$ = yy_rb_str; }
|
||||
| ["] < ( !["] . )* > ["] { $$ = yy_rb_str; }
|
||||
;
|
||||
|
||||
numeric = float
|
||||
| integer
|
||||
;
|
||||
|
||||
float = <'-'? digit+'.'digit+> { $$ = rb_funcall(rb_cObject, rb_intern("Float"), 1, yy_rb_str); }
|
||||
integer = <'-'? digit+> { $$ = rb_funcall(rb_cObject, rb_intern("Integer"), 1, yy_rb_str); }
|
||||
|
||||
|
||||
const = "true" { $$ = Qtrue; }
|
||||
| 'false' { $$ = Qfalse; }
|
||||
| 'nil' { $$ = Qnil; }
|
||||
| 'null' { $$ = Qnil; }
|
||||
;
|
||||
|
||||
digit = [0-9];
|
||||
identifier = [a-zA-Z][a-zA-Z0-9_\-]*[?!]?;
|
||||
|
||||
%%
|
||||
|
||||
VALUE liquid_context_parse_impl(VALUE self, VALUE text) {
|
||||
char *p;
|
||||
int len;
|
||||
yycontext ctx;
|
||||
|
||||
memset(&ctx, 0, sizeof(yycontext));
|
||||
ctx.p = RSTRING_PTR(text);
|
||||
ctx.p_len = (int) RSTRING_LEN(text);
|
||||
ctx.rb_tokens = rb_ary_new();
|
||||
|
||||
yyparse(&ctx);
|
||||
|
||||
return ctx.rb_tokens;
|
||||
}
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -1,159 +0,0 @@
|
||||
/*
|
||||
Parser for context#[] method. Generated through ragel from parser.rl
|
||||
Only modify parser.rl. Run rake ragel afterwards to generate this file.
|
||||
*/
|
||||
|
||||
#include <ruby.h>
|
||||
|
||||
%%{
|
||||
machine fsm;
|
||||
|
||||
action mark {
|
||||
mark = p;
|
||||
}
|
||||
|
||||
action lookup {
|
||||
EMIT("lookup", Qnil)
|
||||
}
|
||||
|
||||
action call {
|
||||
EMIT("call", Qnil)
|
||||
}
|
||||
action range {
|
||||
EMIT("range", Qnil)
|
||||
}
|
||||
|
||||
constants = ( "true" | "false" | "nil" | "null" );
|
||||
|
||||
# strings
|
||||
string = "\"" any* "\"" | "'" any* "'";
|
||||
|
||||
# nothingness
|
||||
nil = "nil" | "null" ;
|
||||
|
||||
# numbers
|
||||
integer = ('+'|'-')? digit+;
|
||||
float = ('+'|'-')? digit+ '.' digit+;
|
||||
|
||||
# simple values
|
||||
primitive = (
|
||||
|
||||
integer >mark %{
|
||||
EMIT("id", rb_funcall(rb_cObject, rb_intern("Integer"), 1, rb_str_new(mark, p - mark)));
|
||||
} |
|
||||
|
||||
float >mark %{
|
||||
EMIT("id", rb_funcall(rb_cObject, rb_intern("Float"), 1, rb_str_new(mark, p - mark)))
|
||||
} |
|
||||
|
||||
nil %{ EMIT("id", Qnil) } |
|
||||
"true" %{ EMIT("id", Qtrue) } |
|
||||
"false" %{ EMIT("id", Qfalse) } |
|
||||
|
||||
string >mark %{ EMIT("id", rb_str_new(mark + 1, p - mark - 2)) }
|
||||
|
||||
);
|
||||
|
||||
entity = (
|
||||
((alpha [A-Za-z0-9_\-]*) - (constants)) >mark %{
|
||||
EMIT("id", rb_str_new(mark, p - mark))
|
||||
EMIT("lookup", Qnil)
|
||||
}
|
||||
);
|
||||
|
||||
# Because of recursion we cannot immediatly resolve the content of this in
|
||||
# the current grammar. We simply re-invoke the parser here to descend into
|
||||
# the substring
|
||||
recur = (
|
||||
(any+ - ']') >mark %{
|
||||
VALUE body = rb_str_new(mark, p - mark);
|
||||
liquid_context_parse_impl(body, tokens);
|
||||
}
|
||||
);
|
||||
|
||||
expr = (
|
||||
entity |
|
||||
primitive |
|
||||
"(" (primitive | entity) ".." (primitive | entity) <: ")" %range |
|
||||
"[" recur "]" %lookup
|
||||
);
|
||||
|
||||
hash_accessors = (
|
||||
"[" recur "]" %call |
|
||||
|
||||
".first" %{
|
||||
EMIT("buildin", rb_str_new2("first"))
|
||||
} |
|
||||
|
||||
".last" %{
|
||||
EMIT("buildin", rb_str_new2("last"))
|
||||
} |
|
||||
|
||||
".size" %{
|
||||
EMIT("buildin", rb_str_new2("size"))
|
||||
} |
|
||||
|
||||
"." ((alpha [A-Za-z0-9_\-]*) - ("first"|"last"|"size")) >mark %{
|
||||
EMIT("id", rb_str_new(mark, p - mark))
|
||||
EMIT("call", Qnil)
|
||||
}
|
||||
);
|
||||
|
||||
main := (
|
||||
|
||||
expr <: (hash_accessors)*
|
||||
|
||||
);
|
||||
|
||||
}%%
|
||||
|
||||
%% write data nofinal;
|
||||
|
||||
// def self.emit(sym, data, tokens)
|
||||
// puts "emitting: #{sym} -> #{data.inspect}" if $VERBOSE
|
||||
// tokens.push [sym, data]
|
||||
// end
|
||||
|
||||
#define EMIT(sym, data) rb_ary_push(tokens, rb_ary_new3(2, ID2SYM(rb_intern(sym)), data));
|
||||
|
||||
|
||||
void liquid_context_parse_impl(VALUE text, VALUE tokens)
|
||||
{
|
||||
char *p;
|
||||
char *pe;
|
||||
char *eof;
|
||||
char *mark;
|
||||
int cs, res = 0;
|
||||
|
||||
if (RSTRING_LEN(text) <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
mark = p = RSTRING_PTR(text);
|
||||
eof = pe = RSTRING_PTR(text) + RSTRING_LEN(text);
|
||||
|
||||
%% write init;
|
||||
%% write exec;
|
||||
}
|
||||
|
||||
VALUE liquid_context_parse(VALUE self, VALUE text) {
|
||||
VALUE tokens;
|
||||
|
||||
//printf("text: %s\n", RSTRING_PTR(text));
|
||||
|
||||
//Check_Type(text, T_STRING);
|
||||
|
||||
tokens = rb_ary_new();
|
||||
liquid_context_parse_impl(text, tokens);
|
||||
return tokens;
|
||||
}
|
||||
|
||||
static VALUE rb_Liquid;
|
||||
static VALUE rb_Parser;
|
||||
|
||||
void Init_liquid_ext()
|
||||
{
|
||||
rb_Liquid = rb_define_module("Liquid");
|
||||
rb_Parser = rb_define_class_under(rb_Liquid, "Parser", rb_cObject);
|
||||
rb_define_singleton_method(rb_Parser, "parse", liquid_context_parse, 1);
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
have_library: checking for main() in -lc... -------------------- yes
|
||||
|
||||
"/usr/bin/gcc-4.2 -o conftest -I/Users/tobi/.rbenv/versions/1.9.3-p194-perf/include/ruby-1.9.1/x86_64-darwin12.0.0 -I/Users/tobi/.rbenv/versions/1.9.3-p194-perf/include/ruby-1.9.1/ruby/backward -I/Users/tobi/.rbenv/versions/1.9.3-p194-perf/include/ruby-1.9.1 -I. -I'/Users/tobi/.rbenv/versions/1.9.3-p194-perf/include' -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I'/Users/tobi/.rbenv/versions/1.9.3-p194-perf/include' -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -pipe conftest.c -L. -L/Users/tobi/.rbenv/versions/1.9.3-p194-perf/lib -L. -L'/Users/tobi/.rbenv/versions/1.9.3-p194-perf/lib' -L/usr/local/lib -lruby-static -lpthread -ldl -lobjc "
|
||||
checked program was:
|
||||
/* begin */
|
||||
1: #include "ruby.h"
|
||||
2:
|
||||
3: int main() {return 0;}
|
||||
/* end */
|
||||
|
||||
"/usr/bin/gcc-4.2 -o conftest -I/Users/tobi/.rbenv/versions/1.9.3-p194-perf/include/ruby-1.9.1/x86_64-darwin12.0.0 -I/Users/tobi/.rbenv/versions/1.9.3-p194-perf/include/ruby-1.9.1/ruby/backward -I/Users/tobi/.rbenv/versions/1.9.3-p194-perf/include/ruby-1.9.1 -I. -I'/Users/tobi/.rbenv/versions/1.9.3-p194-perf/include' -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I'/Users/tobi/.rbenv/versions/1.9.3-p194-perf/include' -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -pipe conftest.c -L. -L/Users/tobi/.rbenv/versions/1.9.3-p194-perf/lib -L. -L'/Users/tobi/.rbenv/versions/1.9.3-p194-perf/lib' -L/usr/local/lib -lruby-static -lc -lpthread -ldl -lobjc "
|
||||
checked program was:
|
||||
/* begin */
|
||||
1: #include "ruby.h"
|
||||
2:
|
||||
3: /*top*/
|
||||
4: int main() {return 0;}
|
||||
5: int t() { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
|
||||
/* end */
|
||||
|
||||
--------------------
|
||||
|
||||
Binary file not shown.
@@ -42,6 +42,7 @@ class ParserTest < Test::Unit::TestCase
|
||||
def test_lookups
|
||||
assert_equal [[:id, "variable"], [:lookup, nil]], Parser.parse('variable')
|
||||
assert_equal [[:id, "underscored_variable"], [:lookup, nil]], Parser.parse('underscored_variable')
|
||||
assert_equal [[:id, "c"], [:lookup, nil]], Parser.parse('c')
|
||||
end
|
||||
|
||||
def test_global_hash
|
||||
@@ -56,6 +57,9 @@ class ParserTest < Test::Unit::TestCase
|
||||
def test_descent
|
||||
assert_equal [[:id, "variable1"], [:lookup, nil], [:id, "variable2"], [:call, nil]], Parser.parse('variable1.variable2')
|
||||
assert_equal [[:id, "variable1"], [:lookup, nil], [:id, "variable2"], [:call, nil], [:id, "variable3"], [:call, nil]], Parser.parse('variable1.variable2.variable3')
|
||||
assert_equal [[:id, "variable1"], [:lookup, nil], [:id, "under_score"], [:call, nil]], Parser.parse('variable1.under_score')
|
||||
assert_equal [[:id, "variable1"], [:lookup, nil], [:id, "question?"], [:call, nil]], Parser.parse('variable1.question?')
|
||||
assert_equal [[:id, "variable1"], [:lookup, nil], [:id, "exclaimation!"], [:call, nil]], Parser.parse('variable1.exclaimation!')
|
||||
end
|
||||
|
||||
def test_descent_hash
|
||||
@@ -76,11 +80,11 @@ class ParserTest < Test::Unit::TestCase
|
||||
assert_equal [[:id, "variable1"], [:lookup, nil], [:id, "test1"], [:lookup, nil], [:id, "test2"], [:call, nil], [:call, nil]],
|
||||
Parser.parse('variable1[test1.test2]'), "resolove: variable1[test1.test2]"
|
||||
|
||||
# assert_equal [[:id, "variable1"], [:lookup, nil], [:id, "test1"], [:lookup, nil], [:id, "test2"], [:call, nil], [:call, nil]],
|
||||
# Parser.parse('variable1[test1["test2"]]'), 'resolove: variable1[test1["test2"]]'
|
||||
assert_equal [[:id, "variable1"], [:lookup, nil], [:id, "test1"], [:lookup, nil], [:id, "test2"], [:call, nil], [:call, nil]],
|
||||
Parser.parse('variable1[test1["test2"]]'), 'resolove: variable1[test1["test2"]]'
|
||||
|
||||
# assert_equal [[:id, "variable1"], [:lookup, nil], [:id, "test1"], [:lookup, nil], [:id, "test2"], [:lookup, nil], [:call, nil], [:call, nil]],
|
||||
# Parser.parse('variable1[test1[test2]]'), "resolove: variable1[test1[test2]]"
|
||||
assert_equal [[:id, "variable1"], [:lookup, nil], [:id, "test1"], [:lookup, nil], [:id, "test2"], [:lookup, nil], [:call, nil], [:call, nil]],
|
||||
Parser.parse('variable1[test1[test2]]'), "resolove: variable1[test1[test2]]"
|
||||
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user