KasmPP(Kasm PreProcessor)
宏匹配大概可以用 Trie 树(前缀树)写吧
% pp command
; comment
tokenize "chars" ; chars -> additional tokenize chars
define sym value
include file
internal system_file
if expr
defined and or not
> = < != >= <=
+ - * / **
& | ! ~
elif expr
else
end
macro rule
body
undef sym
for expr
while expr
env(VAR) nth(0) len(str) system(echo 1) stridx(emm, $i)
let sym = const expr
warn msg
panic msg
inc sym
dec sym
$sym
宏匹配大概可以用 Trie 树(前缀树)写吧
% pp command
; comment
tokenize "chars" ; chars -> additional tokenize chars
define sym value
include file
internal system_file
if expr
defined and or not
> = < != >= <=
+ - * / **
& | ! ~
elif expr
else
end
macro rule
body
undef sym
for expr
while expr
env(VAR) nth(0) len(str) system(echo 1) stridx(emm, $i)
let sym = const expr
warn msg
panic msg
inc sym
dec sym
$sym
Kasm 内部命令表
.file
.section
.import
.export
.type
.align
.size
.ident
.impl
.line
.string
.ascii
.asciz
.label
.goto
(sizeof o) (offset label)
.machine
.linkage
.file
.section
.import
.export
.type
.align
.size
.ident
.impl
.line
.string
.ascii
.asciz
.label
.goto
(sizeof o) (offset label)
.machine
.linkage
Kascm 实现预期
lexer parser string list hash map refcount chunk closure
lexer parser string list hash map refcount chunk closure
(.export main)
(.type function main)
(.impl main)
(push ebp)
(mov ebp esp)
(add eax eax 1)
(mov esi (eaddr - ebp 32))
(pop ebp)
(ret)
ABS CLI
ABS_COLOR ABS_VERBOSE ABS_PKGS_PATH
ABS_COLOR ABS_VERBOSE ABS_PKGS_PATH
-R --pkg-path --require -r
-L --lib-path --lib -l
--debug [socket addr]
--check -c
--check-jvm -cj
-C --chdir
-E --encoding
-A --args
--license
--loop -n
--dump-bytes
--ast-bytes
--pretty
--stream
--interactive -i -repl
--version -version -v
--jvm -J -j
--silent
--verbose
--help -help -h
--code -dc
--lex -dx
--lex-json
--ast -da
--ast-json
--text -cc1
--execute -x
--nocolor
--heap-parser
-D --define
-H --heap-size
--server [address]
in://
out://
err://
https://
https://
file://
code://
pkg://
ApkBundler Scheme
UpValue 由于 JVM 已有 GC 且闭包不需如此实现不需要使用
tailrec heredoc constarg-folding string-templating
exception square brackets call-by-need
BreakLexer
lex-features comment break binop(right left all) keyword
current(frame)
stack
.gotofast1
.gotofast2
.stop
.yield
.wait
.goto
.value
tailrec
.
varargs apend eval pure noreturn noarg onearg twoarg
'(string 's)
UpValue 由于 JVM 已有 GC 且闭包不需如此实现不需要使用
tailrec heredoc constarg-folding string-templating
exception square brackets call-by-need
BreakLexer
lex-features comment break binop(right left all) keyword
current(frame)
stack
.gotofast1
.gotofast2
.stop
.yield
.wait
.goto
.value
tailrec
.
varargs apend eval pure noreturn noarg onearg twoarg
string $templatingstring $(.value 'templating)'(string 's)
org.apkbundler.scheme
text/
Lexer
BreakLexer
(SubSequence)Parser
HeapParser
Token
TokenType
TokenStream
SexpStream
Combinator
type/
Symbol
Reference
Chunk
Closure
Sexp
SexpList
SexpAtom
AbsStack
AbsFrame
port/
ListImpl
HashImpl
StringImpl
StringBuilderImpl
ReflectImpl
error/
Error
LexerError
ParserError
ReferenceError
TypeError
ArgumentError
Errno
ReflectError
ControlFlowTransfer
front/
Main
SchemeDebugger
SchemeServer
SchemeRepl
utils/
Coroutine
SchemeThread
Future
AbsClassLoader
AbsClassPath
AbsClassManager
AutoCloseable
SchemeJava
NumericOperations
AbsTyper
Stdlib
Scheme
text/
Lexer
BreakLexer
(SubSequence)Parser
HeapParser
Token
TokenType
TokenStream
SexpStream
Combinator
type/
Symbol
Reference
Chunk
Closure
Sexp
SexpList
SexpAtom
AbsStack
AbsFrame
port/
ListImpl
HashImpl
StringImpl
StringBuilderImpl
ReflectImpl
error/
Error
LexerError
ParserError
ReferenceError
TypeError
ArgumentError
Errno
ReflectError
ControlFlowTransfer
front/
Main
SchemeDebugger
SchemeServer
SchemeRepl
utils/
Coroutine
SchemeThread
Future
AbsClassLoader
AbsClassPath
AbsClassManager
AutoCloseable
SchemeJava
NumericOperations
AbsTyper
Stdlib
Scheme
GitApk: Android apps with a cup of tea
BeanShell
Beanshell scripting language
Forwarded from dnaugsuz
它可以定义函数可以用循环可以判断分支
但和数学一样基本没有类型概念也不能怎么操作字符串
但和数学一样基本没有类型概念也不能怎么操作字符串
Forwarded from dnaugsuz
(其实就是没人用 MRI Ruby 也要用的,不知道现在 2.6 换 Yacc 没有
说句题外话我上周才知道 MRuby 是基于 Ruby 1.9 开发的,就是第一个基于字节码解释的版本,不过我没有验证
说句题外话我上周才知道 MRuby 是基于 Ruby 1.9 开发的,就是第一个基于字节码解释的版本,不过我没有验证
Forwarded from dnaugsuz
Haiku 没听说过,不知道是更像 UNIX 还是更像 Windows 还是 DOS
Forwarded from dnaugsuz
只知道 BeOS 那个传说纯矢量图的操作系统(
其实这么说有点有失公正了,因为操作系统不全是做 GUI 的
其实这么说有点有失公正了,因为操作系统不全是做 GUI 的
#include <stdio.h>
#include <jit/jit.h>
jit_context_t context;
int main(int argc, char **argv)
{
jit_type_t params[3];
jit_type_t signature;
jit_function_t function;
jit_value_t x, y, z;
jit_value_t temp1, temp2;
jit_int arg1, arg2, arg3;
void *args[3];
jit_int result;
/* Create a context to hold the JIT's primary state */
context = jit_context_create();
/* Lock the context while we build and compile the function */
jit_context_build_start(context);
/* Build the function signature */
params[0] = jit_type_int;
params[1] = jit_type_int;
params[2] = jit_type_int;
signature = jit_type_create_signature
(jit_abi_cdecl, jit_type_int, params, 3, 1);
/* Create the function object */
function = jit_function_create(context, signature);
jit_type_free(signature);
/* Construct the function body */
x = jit_value_get_param(function, 0);
y = jit_value_get_param(function, 1);
z = jit_value_get_param(function, 2);
temp1 = jit_insn_mul(function, x, y);
temp2 = jit_insn_add(function, temp1, z);
jit_insn_return(function, temp2);
/* Compile the function */
jit_function_compile(function);
/* Unlock the context */
jit_context_build_end(context);
/* Execute the function and print the result */
arg1 = 3;
arg2 = 5;
arg3 = 2;
args[0] = &arg1;
args[1] = &arg2;
args[2] = &arg3;
jit_function_apply(function, args, &result);
printf("mul_add(3, 5, 2) = %d\n", (int)result);
/* Clean up */
jit_context_destroy(context);
/* Finished */
return 0;
}
#include <jit/jit.h>
jit_context_t context;
int main(int argc, char **argv)
{
jit_type_t params[3];
jit_type_t signature;
jit_function_t function;
jit_value_t x, y, z;
jit_value_t temp1, temp2;
jit_int arg1, arg2, arg3;
void *args[3];
jit_int result;
/* Create a context to hold the JIT's primary state */
context = jit_context_create();
/* Lock the context while we build and compile the function */
jit_context_build_start(context);
/* Build the function signature */
params[0] = jit_type_int;
params[1] = jit_type_int;
params[2] = jit_type_int;
signature = jit_type_create_signature
(jit_abi_cdecl, jit_type_int, params, 3, 1);
/* Create the function object */
function = jit_function_create(context, signature);
jit_type_free(signature);
/* Construct the function body */
x = jit_value_get_param(function, 0);
y = jit_value_get_param(function, 1);
z = jit_value_get_param(function, 2);
temp1 = jit_insn_mul(function, x, y);
temp2 = jit_insn_add(function, temp1, z);
jit_insn_return(function, temp2);
/* Compile the function */
jit_function_compile(function);
/* Unlock the context */
jit_context_build_end(context);
/* Execute the function and print the result */
arg1 = 3;
arg2 = 5;
arg3 = 2;
args[0] = &arg1;
args[1] = &arg2;
args[2] = &arg3;
jit_function_apply(function, args, &result);
printf("mul_add(3, 5, 2) = %d\n", (int)result);
/* Clean up */
jit_context_destroy(context);
/* Finished */
return 0;
}