Skip to content

Commit

Permalink
optscript: initial commit
Browse files Browse the repository at this point in the history
optscript is an implementation of postscript alike general purpose language.
It will be linked to ctags for extending optlib parsers in the future.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
  • Loading branch information
masatake committed May 2, 2021
1 parent d8a63e0 commit d8f6b0e
Show file tree
Hide file tree
Showing 44 changed files with 5,526 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ mini-geany
mini-geany.exe
missing
mkinstalldirs
optscript
perf.data*
readtags
readtags.exe
Expand Down
14 changes: 13 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ endif

PARSER_HEADS += $(PEG_EXTRA_HEADS)

libctags_a_CPPFLAGS = -I. -I$(srcdir) -I$(srcdir)/main -I$(srcdir)/peg -DHAVE_PACKCC
libctags_a_CPPFLAGS = -I. -I$(srcdir) -I$(srcdir)/main -I$(srcdir)/dsl -I$(srcdir)/peg -DHAVE_PACKCC
if ENABLE_DEBUGGING
libctags_a_CPPFLAGS+= $(DEBUG_CPPFLAGS)
endif
Expand Down Expand Up @@ -194,6 +194,18 @@ mini_geany_LDADD += $(SECCOMP_LIBS)
mini_geany_LDADD += $(ICONV_LIBS)
mini_geany_SOURCES = $(MINI_GEANY_HEADS) $(MINI_GEANY_SRCS)

bin_PROGRAMS += optscript
optscript_CPPFLAGS = $(libctags_a_CPPFLAGS)
optscript_CFLAGS = $(libctags_a_CFLAGS)
optscript_LDADD = libctags.a
# TODO: remove these dependencies from optscript command.
optscript_LDADD += $(LIBXML_LIBS)
optscript_LDADD += $(JANSSON_LIBS)
optscript_LDADD += $(LIBYAML_LIBS)
optscript_LDADD += $(SECCOMP_LIBS)
optscript_LDADD += $(ICONV_LIBS)
optscript_SOURCES = $(OPTSCRIPT_SRCS)

if INSTALL_ETAGS
install-exec-hook:
cd $(DESTDIR)$(bindir) && \
Expand Down
18 changes: 18 additions & 0 deletions Tmain/optscript.d/arithmetic.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
8
(3 5 add)
33
(99 3 idiv)
4
(99 5 mod)
30
(3 10 mul)
-12
(8 20 sub)
3
(-3 neg)
-3
(3 neg)
3
(-3 abs)
3
(3 abs)
Binary file added Tmain/optscript.d/arithmetic.ps
Binary file not shown.
8 changes: 8 additions & 0 deletions Tmain/optscript.d/array.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[null null null null null]
[1 2 3]
3
2
1
/a
[1 2 3]
/a
Binary file added Tmain/optscript.d/array.ps
Binary file not shown.
159 changes: 159 additions & 0 deletions Tmain/optscript.d/compound.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
3
(abc)
2
-dict:2-
3
[true false null]
(abc)
true
true
false
[true false null]
(---------------- get array ----------------)
(a)
(a ->)
(b)
(b ->)
(c)
(c ->)
true
3
[(a) (b) (c)]
(true ->)
(---------------- get dict ----------------)
(a)
(a ->)
(b)
(b ->)
(c)
(c ->)
true
false
-dict:3-
(true ->)
(---------------- get str ----------------)
97
(97 ->)
98
(98 ->)
99
(99 ->)
true
3
(abc)
(true ->)
(---------------- forall array ----------------)
6
(6 -> )
(---------------- forall dict values ----------------)
6
(6 -> )
(---------------- forall dict keys ----------------)
false
(false ->)
(---------------- forall string ----------------)
294
(294 ->)
(---------------- put string ----------------)
(abc)
(\(abc\) ->)
(abcd)
(\(abcd\) ->)
(abc e)
(\(abc e\) ->)
(---------------- put array ----------------)
[/a /b /c]
([/a /b /c] ->)
[/a /b /c /d]
([/a /b /c /d] ->)
[/a /b /c null /e]
([/a /b /c null /e] ->)
(---------------- put dict ----------------)
1
(1 ->)
(---------------- putinterval string ----------------)
(xyzdef)
(\(xyzdef\) ->)
(xyz123)
(\(xyz123\) ->)
(xyz1234)
(\(xyz1234\) ->)
(abcdex)
(\(abcdex\) ->)
(abcdefx)
(\(abcdefx\) ->)
(abcdxf)
(\(abcdxf\) ->)
(abcdxyz)
(\(abcdxyz\) ->)
(---------------- putinterval array ----------------)
[/x /b /c]
([/x /b /c] ->)
[/a /x /c]
([/a /x /c] ->)
[/a /b /x]
([/a /b /x] ->)
[/a /b /c /x]
([/a /b /c /x] ->)
[/a /b /c /x /y]
([/a /b /c /x /y] ->)
[/a /b /x /y]
([/a /b /x /y] ->)
[/a /x /y]
([/a /x /y] ->)
[/x /y /c]
([/x /y /c] ->)
[/x /y /z]
([/x /y /z] ->)
[/a /x /y /z]
([/a /x /y /z] ->)
[/a /b /x /y /z]
([/a /b /x /y /z] ->)
[/a /b /c /x /y /z]
([/a /b /c /x /y /z] ->)
[/a /b /c /x /y /z /1]
([/a /b /c /x /y /z /1] ->)
[/a /b /x /y /z /1]
([/a /b /x /y /z /1] ->)
[/a /x /y /z /1]
([/a /x /y /z /1] ->)
[/x /y /z /1]
([/x /y /z /1] ->)
(---------------- _copyinterval string ----------------)
()
(\(\) ->)
(1)
(\(1\) ->)
(a)
(\(a\) ->)
(1a)
(\(1a\) ->)
(ab)
(\(ab\) ->)
(bc)
(\(bc\) ->)
(cde)
(\(cde\) ->)
(e)
(\(e\) ->)
()
(\(\) ->)
(---------------- _copyinterval array ----------------)
[]
([] ->)
[1]
([1] ->)
[/a]
([/a] ->)
[1 /a]
([1 /a] ->)
[/a /b]
([ /a /b ] ->)
[/b /c]
([/b /c] ->)
[/c /d /e]
([/c /d /e] ->)
[/e]
([/e] ->)
[]
([] ->)
Binary file added Tmain/optscript.d/compound.ps
Binary file not shown.
36 changes: 36 additions & 0 deletions Tmain/optscript.d/control.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
5
12
12
(string)
(executed if block)
(executed if block)
(executed else block)
2
1
0
4
3
2
1
0
[(jump here as expected) true /undefined]
[(jump here as expected) false null]
5
-1
-2
-3
-4
-5
1
3
5
7
9
(---------------- countexecstack ----------------)
3
(---------------- execstack ----------------)
[]
(---------------- exception handling ----------------)
(OK: this code just after loop should be executed)
(OK: 'exit' should not be caught here.)
(OK: 'stop' should be caught here.)
Binary file added Tmain/optscript.d/control.ps
Binary file not shown.
22 changes: 22 additions & 0 deletions Tmain/optscript.d/dict.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
3
true
false
true
-dict:1-
false
3
2
1
(a)
false
2
3
2
(---- dictstack & cleardictstack ----)
3
4
2
(---- store ----)
1
-dict:1-
null
Binary file added Tmain/optscript.d/dict.ps
Binary file not shown.
7 changes: 7 additions & 0 deletions Tmain/optscript.d/error-undefined-if-if.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Error: /undefined in a
Operand stack:
top| |bottom
Execution stack:
top| a {a} --if-- {true {a} if} --if-- |bottom
Dictionary stack:
top| -dict:1- -dict:87- |bottom
Binary file added Tmain/optscript.d/error-undefined-if-if.ps
Binary file not shown.
7 changes: 7 additions & 0 deletions Tmain/optscript.d/error-undefined-if.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Error: /undefined in a
Operand stack:
top| |bottom
Execution stack:
top| a {a} --if-- |bottom
Dictionary stack:
top| -dict:1- -dict:87- |bottom
Binary file added Tmain/optscript.d/error-undefined-if.ps
Binary file not shown.
1 change: 1 addition & 0 deletions Tmain/optscript.d/exit-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
5 changes: 5 additions & 0 deletions Tmain/optscript.d/misc.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(--------------- bind ---------------)
{--add-- {--add--}}
({--add-- {--add--}} ->)
1
{--[-- 1 1 --add-- --]--}
Binary file added Tmain/optscript.d/misc.ps
Binary file not shown.
14 changes: 14 additions & 0 deletions Tmain/optscript.d/pstack.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
false
true
null
-dict:1-
[{/add} {add}]
{/add}
{add}
{/a /b /c}
[/a /b /c]
[1 2 3]
-mark-
(abc)
/a
1
Binary file added Tmain/optscript.d/pstack.ps
Binary file not shown.
Loading

0 comments on commit d8f6b0e

Please sign in to comment.