moved scripts to the scripts directory.
added a embedding sample in c
This commit is contained in:
parent
4ee104e1ee
commit
c45114458e
@ -13,14 +13,14 @@ Hawk implements most of the AWK programming language elements with extensions.
|
|||||||
|
|
||||||
You may change the entry point of your script by setting a function name with @pragma entry.
|
You may change the entry point of your script by setting a function name with @pragma entry.
|
||||||
|
|
||||||
<pre>
|
```
|
||||||
@pragma entry main
|
@pragma entry main
|
||||||
|
|
||||||
function main ()
|
function main ()
|
||||||
{
|
{
|
||||||
print "hello, world";
|
print "hello, world";
|
||||||
}
|
}
|
||||||
</pre>
|
```
|
||||||
|
|
||||||
### Value
|
### Value
|
||||||
|
|
||||||
@ -41,22 +41,24 @@ function main ()
|
|||||||
|
|
||||||
In AWK, the caller can pass an uninitialized variable as a function parameter and get a changed value if the callled function sets it to an array.
|
In AWK, the caller can pass an uninitialized variable as a function parameter and get a changed value if the callled function sets it to an array.
|
||||||
|
|
||||||
<pre>
|
```
|
||||||
function q(a) {a[1]=20; a[2]=30;}
|
function q(a) {a[1]=20; a[2]=30;}
|
||||||
BEGIN { q(x); for (i in x) print i, x[i]; }
|
BEGIN { q(x); for (i in x) print i, x[i]; }
|
||||||
</pre>
|
```
|
||||||
|
|
||||||
In Hawk, you can prefix the pramater name with & to indicate call-by-reference for the same effect.
|
In Hawk, you can prefix the pramater name with & to indicate call-by-reference for the same effect.
|
||||||
<pre>
|
|
||||||
|
```
|
||||||
function q(&a) {a[1]=20; a[2]=30;}
|
function q(&a) {a[1]=20; a[2]=30;}
|
||||||
BEGIN { q(x); for (i in x) print i, x[i]; }
|
BEGIN { q(x); for (i in x) print i, x[i]; }
|
||||||
</pre>
|
```
|
||||||
|
|
||||||
Alternatively, you may form an array before passing it to a function.
|
Alternatively, you may form an array before passing it to a function.
|
||||||
<pre>
|
|
||||||
|
```
|
||||||
function q(a) {a[1]=20; a[2]=30;}
|
function q(a) {a[1]=20; a[2]=30;}
|
||||||
BEGIN { x[3]=99; q(x); for (i in x) print i, x[i]; }'
|
BEGIN { x[3]=99; q(x); for (i in x) print i, x[i]; }'
|
||||||
</pre>
|
```
|
||||||
|
|
||||||
|
|
||||||
## Basic Modules <a name="basic-modules"></a>
|
## Basic Modules <a name="basic-modules"></a>
|
||||||
@ -68,3 +70,80 @@ BEGIN { x[3]=99; q(x); for (i in x) print i, x[i]; }'
|
|||||||
### mysql
|
### mysql
|
||||||
|
|
||||||
## Embedding Guide <a name="embedding-guide"></a>
|
## Embedding Guide <a name="embedding-guide"></a>
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
#include <hawk-std.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
static const hawk_bch_t* src =
|
||||||
|
"BEGIN {"
|
||||||
|
" for (i=2;i<=9;i++)"
|
||||||
|
" {"
|
||||||
|
" for (j=1;j<=9;j++)"
|
||||||
|
" print i \"*\" j \"=\" i * j;"
|
||||||
|
" print \"---------------------\";"
|
||||||
|
" }"
|
||||||
|
"}";
|
||||||
|
|
||||||
|
int main ()
|
||||||
|
{
|
||||||
|
hawk_t* hawk = HAWK_NULL;
|
||||||
|
hawk_rtx_t* rtx = HAWK_NULL;
|
||||||
|
hawk_val_t* retv;
|
||||||
|
|
||||||
|
hawk_parsestd_t psin[2];
|
||||||
|
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
hawk = hawk_openstd(0, HAWK_NULL);
|
||||||
|
if (!hawk)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "ERROR: cannot open hawk\n");
|
||||||
|
ret = -1; goto oops;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset (&psin, 0, HAWK_SIZEOF(psin));
|
||||||
|
psin[0].type = HAWK_PARSESTD_BCS;
|
||||||
|
psin[0].u.bcs.ptr = (hawk_bch_t*)src;
|
||||||
|
psin[0].u.bcs.len = hawk_count_bcstr(src);
|
||||||
|
psin[1].type = HAWK_PARSESTD_NULL;
|
||||||
|
|
||||||
|
ret = hawk_parsestd(hawk, psin, HAWK_NULL);
|
||||||
|
if (ret <= -1)
|
||||||
|
{
|
||||||
|
hawk_logbfmt (hawk, HAWK_LOG_STDERR, "ERROR(parse): %js\n", hawk_geterrmsg(hawk));
|
||||||
|
ret = -1; goto oops;
|
||||||
|
}
|
||||||
|
|
||||||
|
rtx = hawk_rtx_openstd (
|
||||||
|
hawk,
|
||||||
|
0,
|
||||||
|
HAWK_T("hawk02"),
|
||||||
|
HAWK_NULL, /* stdin */
|
||||||
|
HAWK_NULL, /* stdout */
|
||||||
|
HAWK_NULL /* default cmgr */
|
||||||
|
);
|
||||||
|
if (!rtx)
|
||||||
|
{
|
||||||
|
hawk_logbfmt (hawk, HAWK_LOG_STDERR, "ERROR(rtx_open): %js\n", hawk_geterrmsg(hawk));
|
||||||
|
ret = -1; goto oops;
|
||||||
|
}
|
||||||
|
|
||||||
|
retv = hawk_rtx_loop(rtx);
|
||||||
|
if (!retv)
|
||||||
|
{
|
||||||
|
hawk_logbfmt (hawk, HAWK_LOG_STDERR, "ERROR(rtx_loop): %js\n", hawk_geterrmsg(hawk));
|
||||||
|
ret = -1; goto oops;
|
||||||
|
}
|
||||||
|
|
||||||
|
hawk_rtx_refdownval (rtx, retv);
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
oops:
|
||||||
|
if (rtx) hawk_rtx_close (rtx);
|
||||||
|
if (hawk) hawk_close (hawk);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
@ -19,7 +19,13 @@ bin_PROGRAMS =
|
|||||||
|
|
||||||
if ENABLE_CXX
|
if ENABLE_CXX
|
||||||
|
|
||||||
bin_PROGRAMS += hawk51
|
bin_PROGRAMS += hawk02 hawk51
|
||||||
|
|
||||||
|
hawk02_SOURCES = hawk02.c
|
||||||
|
hawk02_CPPFLAGS = $(CPPFLAGS_ALL_COMMON)
|
||||||
|
hawk02_LDFLAGS = $(LDFLAGS_ALL_COMMON)
|
||||||
|
hawk02_LDADD = -lhawk $(LIBADD_BIN_COMMON) $(SOCKET_LIBS)
|
||||||
|
hawk02_DEPENDENCIES = ../lib/libhawk.la
|
||||||
|
|
||||||
hawk51_SOURCES = hawk51.cpp
|
hawk51_SOURCES = hawk51.cpp
|
||||||
hawk51_CPPFLAGS = $(CPPFLAGS_ALL_COMMON)
|
hawk51_CPPFLAGS = $(CPPFLAGS_ALL_COMMON)
|
||||||
|
@ -89,7 +89,7 @@ POST_UNINSTALL = :
|
|||||||
build_triplet = @build@
|
build_triplet = @build@
|
||||||
host_triplet = @host@
|
host_triplet = @host@
|
||||||
bin_PROGRAMS = $(am__EXEEXT_1)
|
bin_PROGRAMS = $(am__EXEEXT_1)
|
||||||
@ENABLE_CXX_TRUE@am__append_1 = hawk51
|
@ENABLE_CXX_TRUE@am__append_1 = hawk02 hawk51
|
||||||
subdir = samples
|
subdir = samples
|
||||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||||
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
|
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
|
||||||
@ -107,18 +107,24 @@ mkinstalldirs = $(install_sh) -d
|
|||||||
CONFIG_HEADER = $(top_builddir)/lib/hawk-cfg.h
|
CONFIG_HEADER = $(top_builddir)/lib/hawk-cfg.h
|
||||||
CONFIG_CLEAN_FILES =
|
CONFIG_CLEAN_FILES =
|
||||||
CONFIG_CLEAN_VPATH_FILES =
|
CONFIG_CLEAN_VPATH_FILES =
|
||||||
@ENABLE_CXX_TRUE@am__EXEEXT_1 = hawk51$(EXEEXT)
|
@ENABLE_CXX_TRUE@am__EXEEXT_1 = hawk02$(EXEEXT) hawk51$(EXEEXT)
|
||||||
am__installdirs = "$(DESTDIR)$(bindir)"
|
am__installdirs = "$(DESTDIR)$(bindir)"
|
||||||
PROGRAMS = $(bin_PROGRAMS)
|
PROGRAMS = $(bin_PROGRAMS)
|
||||||
am__hawk51_SOURCES_DIST = hawk51.cpp
|
am__hawk02_SOURCES_DIST = hawk02.c
|
||||||
@ENABLE_CXX_TRUE@am_hawk51_OBJECTS = hawk51-hawk51.$(OBJEXT)
|
@ENABLE_CXX_TRUE@am_hawk02_OBJECTS = hawk02-hawk02.$(OBJEXT)
|
||||||
hawk51_OBJECTS = $(am_hawk51_OBJECTS)
|
hawk02_OBJECTS = $(am_hawk02_OBJECTS)
|
||||||
am__DEPENDENCIES_1 =
|
am__DEPENDENCIES_1 =
|
||||||
am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
|
am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
|
||||||
AM_V_lt = $(am__v_lt_@AM_V@)
|
AM_V_lt = $(am__v_lt_@AM_V@)
|
||||||
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
|
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
|
||||||
am__v_lt_0 = --silent
|
am__v_lt_0 = --silent
|
||||||
am__v_lt_1 =
|
am__v_lt_1 =
|
||||||
|
hawk02_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||||
|
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||||
|
$(hawk02_LDFLAGS) $(LDFLAGS) -o $@
|
||||||
|
am__hawk51_SOURCES_DIST = hawk51.cpp
|
||||||
|
@ENABLE_CXX_TRUE@am_hawk51_OBJECTS = hawk51-hawk51.$(OBJEXT)
|
||||||
|
hawk51_OBJECTS = $(am_hawk51_OBJECTS)
|
||||||
hawk51_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
|
hawk51_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
|
||||||
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
|
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
|
||||||
$(CXXFLAGS) $(hawk51_LDFLAGS) $(LDFLAGS) -o $@
|
$(CXXFLAGS) $(hawk51_LDFLAGS) $(LDFLAGS) -o $@
|
||||||
@ -137,8 +143,27 @@ am__v_at_1 =
|
|||||||
DEFAULT_INCLUDES =
|
DEFAULT_INCLUDES =
|
||||||
depcomp = $(SHELL) $(top_srcdir)/ac/depcomp
|
depcomp = $(SHELL) $(top_srcdir)/ac/depcomp
|
||||||
am__maybe_remake_depfiles = depfiles
|
am__maybe_remake_depfiles = depfiles
|
||||||
am__depfiles_remade = ./$(DEPDIR)/hawk51-hawk51.Po
|
am__depfiles_remade = ./$(DEPDIR)/hawk02-hawk02.Po \
|
||||||
|
./$(DEPDIR)/hawk51-hawk51.Po
|
||||||
am__mv = mv -f
|
am__mv = mv -f
|
||||||
|
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||||
|
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||||
|
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||||
|
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
|
||||||
|
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
|
||||||
|
$(AM_CFLAGS) $(CFLAGS)
|
||||||
|
AM_V_CC = $(am__v_CC_@AM_V@)
|
||||||
|
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
|
||||||
|
am__v_CC_0 = @echo " CC " $@;
|
||||||
|
am__v_CC_1 =
|
||||||
|
CCLD = $(CC)
|
||||||
|
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||||
|
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||||
|
$(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||||
|
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
|
||||||
|
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
|
||||||
|
am__v_CCLD_0 = @echo " CCLD " $@;
|
||||||
|
am__v_CCLD_1 =
|
||||||
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
|
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
|
||||||
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||||
LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
|
LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
|
||||||
@ -157,8 +182,8 @@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
|
|||||||
am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
|
am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
|
||||||
am__v_CXXLD_0 = @echo " CXXLD " $@;
|
am__v_CXXLD_0 = @echo " CXXLD " $@;
|
||||||
am__v_CXXLD_1 =
|
am__v_CXXLD_1 =
|
||||||
SOURCES = $(hawk51_SOURCES)
|
SOURCES = $(hawk02_SOURCES) $(hawk51_SOURCES)
|
||||||
DIST_SOURCES = $(am__hawk51_SOURCES_DIST)
|
DIST_SOURCES = $(am__hawk02_SOURCES_DIST) $(am__hawk51_SOURCES_DIST)
|
||||||
am__can_run_installinfo = \
|
am__can_run_installinfo = \
|
||||||
case $$AM_UPDATE_INFO_DIR in \
|
case $$AM_UPDATE_INFO_DIR in \
|
||||||
n|no|NO) false;; \
|
n|no|NO) false;; \
|
||||||
@ -356,6 +381,11 @@ LDFLAGS_ALL_COMMON = -L$(abs_builddir) -L$(abs_builddir)/../lib -L$(libdir)
|
|||||||
CPPFLAGS_BIN_COMMON = $(CPPFLAGS_ALL_COMMON)
|
CPPFLAGS_BIN_COMMON = $(CPPFLAGS_ALL_COMMON)
|
||||||
LDFLAGS_BIN_COMMON = $(LDFLAGS_ALL_COMMON) -no-undefined
|
LDFLAGS_BIN_COMMON = $(LDFLAGS_ALL_COMMON) -no-undefined
|
||||||
LIBADD_BIN_COMMON = $(LIBM)
|
LIBADD_BIN_COMMON = $(LIBM)
|
||||||
|
@ENABLE_CXX_TRUE@hawk02_SOURCES = hawk02.c
|
||||||
|
@ENABLE_CXX_TRUE@hawk02_CPPFLAGS = $(CPPFLAGS_ALL_COMMON)
|
||||||
|
@ENABLE_CXX_TRUE@hawk02_LDFLAGS = $(LDFLAGS_ALL_COMMON)
|
||||||
|
@ENABLE_CXX_TRUE@hawk02_LDADD = -lhawk $(LIBADD_BIN_COMMON) $(SOCKET_LIBS)
|
||||||
|
@ENABLE_CXX_TRUE@hawk02_DEPENDENCIES = ../lib/libhawk.la
|
||||||
@ENABLE_CXX_TRUE@hawk51_SOURCES = hawk51.cpp
|
@ENABLE_CXX_TRUE@hawk51_SOURCES = hawk51.cpp
|
||||||
@ENABLE_CXX_TRUE@hawk51_CPPFLAGS = $(CPPFLAGS_ALL_COMMON)
|
@ENABLE_CXX_TRUE@hawk51_CPPFLAGS = $(CPPFLAGS_ALL_COMMON)
|
||||||
@ENABLE_CXX_TRUE@hawk51_LDFLAGS = $(LDFLAGS_ALL_COMMON)
|
@ENABLE_CXX_TRUE@hawk51_LDFLAGS = $(LDFLAGS_ALL_COMMON)
|
||||||
@ -364,7 +394,7 @@ LIBADD_BIN_COMMON = $(LIBM)
|
|||||||
all: all-am
|
all: all-am
|
||||||
|
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
.SUFFIXES: .cpp .lo .o .obj
|
.SUFFIXES: .c .cpp .lo .o .obj
|
||||||
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
||||||
@for dep in $?; do \
|
@for dep in $?; do \
|
||||||
case '$(am__configure_deps)' in \
|
case '$(am__configure_deps)' in \
|
||||||
@ -444,6 +474,10 @@ clean-binPROGRAMS:
|
|||||||
echo " rm -f" $$list; \
|
echo " rm -f" $$list; \
|
||||||
rm -f $$list
|
rm -f $$list
|
||||||
|
|
||||||
|
hawk02$(EXEEXT): $(hawk02_OBJECTS) $(hawk02_DEPENDENCIES) $(EXTRA_hawk02_DEPENDENCIES)
|
||||||
|
@rm -f hawk02$(EXEEXT)
|
||||||
|
$(AM_V_CCLD)$(hawk02_LINK) $(hawk02_OBJECTS) $(hawk02_LDADD) $(LIBS)
|
||||||
|
|
||||||
hawk51$(EXEEXT): $(hawk51_OBJECTS) $(hawk51_DEPENDENCIES) $(EXTRA_hawk51_DEPENDENCIES)
|
hawk51$(EXEEXT): $(hawk51_OBJECTS) $(hawk51_DEPENDENCIES) $(EXTRA_hawk51_DEPENDENCIES)
|
||||||
@rm -f hawk51$(EXEEXT)
|
@rm -f hawk51$(EXEEXT)
|
||||||
$(AM_V_CXXLD)$(hawk51_LINK) $(hawk51_OBJECTS) $(hawk51_LDADD) $(LIBS)
|
$(AM_V_CXXLD)$(hawk51_LINK) $(hawk51_OBJECTS) $(hawk51_LDADD) $(LIBS)
|
||||||
@ -454,6 +488,7 @@ mostlyclean-compile:
|
|||||||
distclean-compile:
|
distclean-compile:
|
||||||
-rm -f *.tab.c
|
-rm -f *.tab.c
|
||||||
|
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hawk02-hawk02.Po@am__quote@ # am--include-marker
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hawk51-hawk51.Po@am__quote@ # am--include-marker
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hawk51-hawk51.Po@am__quote@ # am--include-marker
|
||||||
|
|
||||||
$(am__depfiles_remade):
|
$(am__depfiles_remade):
|
||||||
@ -462,6 +497,44 @@ $(am__depfiles_remade):
|
|||||||
|
|
||||||
am--depfiles: $(am__depfiles_remade)
|
am--depfiles: $(am__depfiles_remade)
|
||||||
|
|
||||||
|
.c.o:
|
||||||
|
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
|
||||||
|
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
|
||||||
|
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
|
||||||
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||||
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||||
|
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
|
||||||
|
|
||||||
|
.c.obj:
|
||||||
|
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
|
||||||
|
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
|
||||||
|
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
|
||||||
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||||
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||||
|
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
|
||||||
|
|
||||||
|
.c.lo:
|
||||||
|
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
|
||||||
|
@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
|
||||||
|
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
|
||||||
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
|
||||||
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||||
|
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
|
||||||
|
|
||||||
|
hawk02-hawk02.o: hawk02.c
|
||||||
|
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hawk02_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hawk02-hawk02.o -MD -MP -MF $(DEPDIR)/hawk02-hawk02.Tpo -c -o hawk02-hawk02.o `test -f 'hawk02.c' || echo '$(srcdir)/'`hawk02.c
|
||||||
|
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hawk02-hawk02.Tpo $(DEPDIR)/hawk02-hawk02.Po
|
||||||
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='hawk02.c' object='hawk02-hawk02.o' libtool=no @AMDEPBACKSLASH@
|
||||||
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||||
|
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hawk02_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hawk02-hawk02.o `test -f 'hawk02.c' || echo '$(srcdir)/'`hawk02.c
|
||||||
|
|
||||||
|
hawk02-hawk02.obj: hawk02.c
|
||||||
|
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hawk02_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hawk02-hawk02.obj -MD -MP -MF $(DEPDIR)/hawk02-hawk02.Tpo -c -o hawk02-hawk02.obj `if test -f 'hawk02.c'; then $(CYGPATH_W) 'hawk02.c'; else $(CYGPATH_W) '$(srcdir)/hawk02.c'; fi`
|
||||||
|
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hawk02-hawk02.Tpo $(DEPDIR)/hawk02-hawk02.Po
|
||||||
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='hawk02.c' object='hawk02-hawk02.obj' libtool=no @AMDEPBACKSLASH@
|
||||||
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||||
|
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hawk02_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hawk02-hawk02.obj `if test -f 'hawk02.c'; then $(CYGPATH_W) 'hawk02.c'; else $(CYGPATH_W) '$(srcdir)/hawk02.c'; fi`
|
||||||
|
|
||||||
.cpp.o:
|
.cpp.o:
|
||||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
|
@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
|
||||||
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
|
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
|
||||||
@ -633,6 +706,7 @@ clean: clean-am
|
|||||||
clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
|
clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
|
||||||
|
|
||||||
distclean: distclean-am
|
distclean: distclean-am
|
||||||
|
-rm -f ./$(DEPDIR)/hawk02-hawk02.Po
|
||||||
-rm -f ./$(DEPDIR)/hawk51-hawk51.Po
|
-rm -f ./$(DEPDIR)/hawk51-hawk51.Po
|
||||||
-rm -f Makefile
|
-rm -f Makefile
|
||||||
distclean-am: clean-am distclean-compile distclean-generic \
|
distclean-am: clean-am distclean-compile distclean-generic \
|
||||||
@ -679,6 +753,7 @@ install-ps-am:
|
|||||||
installcheck-am:
|
installcheck-am:
|
||||||
|
|
||||||
maintainer-clean: maintainer-clean-am
|
maintainer-clean: maintainer-clean-am
|
||||||
|
-rm -f ./$(DEPDIR)/hawk02-hawk02.Po
|
||||||
-rm -f ./$(DEPDIR)/hawk51-hawk51.Po
|
-rm -f ./$(DEPDIR)/hawk51-hawk51.Po
|
||||||
-rm -f Makefile
|
-rm -f Makefile
|
||||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||||
|
74
hawk/samples/hawk02.c
Normal file
74
hawk/samples/hawk02.c
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
#include <hawk-std.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
static const hawk_bch_t* src =
|
||||||
|
"BEGIN {"
|
||||||
|
" for (i=2;i<=9;i++)"
|
||||||
|
" {"
|
||||||
|
" for (j=1;j<=9;j++)"
|
||||||
|
" print i \"*\" j \"=\" i * j;"
|
||||||
|
" print \"---------------------\";"
|
||||||
|
" }"
|
||||||
|
"}";
|
||||||
|
|
||||||
|
int main ()
|
||||||
|
{
|
||||||
|
hawk_t* hawk = HAWK_NULL;
|
||||||
|
hawk_rtx_t* rtx = HAWK_NULL;
|
||||||
|
hawk_val_t* retv;
|
||||||
|
|
||||||
|
hawk_parsestd_t psin[2];
|
||||||
|
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
hawk = hawk_openstd(0, HAWK_NULL);
|
||||||
|
if (!hawk)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "ERROR: cannot open hawk\n");
|
||||||
|
ret = -1; goto oops;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset (&psin, 0, HAWK_SIZEOF(psin));
|
||||||
|
psin[0].type = HAWK_PARSESTD_BCS;
|
||||||
|
psin[0].u.bcs.ptr = (hawk_bch_t*)src;
|
||||||
|
psin[0].u.bcs.len = hawk_count_bcstr(src);
|
||||||
|
psin[1].type = HAWK_PARSESTD_NULL;
|
||||||
|
|
||||||
|
ret = hawk_parsestd(hawk, psin, HAWK_NULL);
|
||||||
|
if (ret <= -1)
|
||||||
|
{
|
||||||
|
hawk_logbfmt (hawk, HAWK_LOG_STDERR, "ERROR(parse): %js\n", hawk_geterrmsg(hawk));
|
||||||
|
ret = -1; goto oops;
|
||||||
|
}
|
||||||
|
|
||||||
|
rtx = hawk_rtx_openstd (
|
||||||
|
hawk,
|
||||||
|
0,
|
||||||
|
HAWK_T("hawk02"),
|
||||||
|
HAWK_NULL, /* stdin */
|
||||||
|
HAWK_NULL, /* stdout */
|
||||||
|
HAWK_NULL /* default cmgr */
|
||||||
|
);
|
||||||
|
if (!rtx)
|
||||||
|
{
|
||||||
|
hawk_logbfmt (hawk, HAWK_LOG_STDERR, "ERROR(rtx_open): %js\n", hawk_geterrmsg(hawk));
|
||||||
|
ret = -1; goto oops;
|
||||||
|
}
|
||||||
|
|
||||||
|
retv = hawk_rtx_loop(rtx);
|
||||||
|
if (!retv)
|
||||||
|
{
|
||||||
|
hawk_logbfmt (hawk, HAWK_LOG_STDERR, "ERROR(rtx_loop): %js\n", hawk_geterrmsg(hawk));
|
||||||
|
ret = -1; goto oops;
|
||||||
|
}
|
||||||
|
|
||||||
|
hawk_rtx_refdownval (rtx, retv);
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
oops:
|
||||||
|
if (rtx) hawk_rtx_close (rtx);
|
||||||
|
if (hawk) hawk_close (hawk);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# genoptcode.awk
|
# genoptcode.awk
|
||||||
#
|
#
|
||||||
# hawk -f generror.awk hawk.h
|
# hawk -f genoptcode.awk hawk.h
|
||||||
#
|
#
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
Loading…
Reference in New Issue
Block a user