Skip to content

Releases: bajdcc/jMiniLang

Spring Boot API -- Web Server

20 Jun 11:11
Compare
Choose a tag to compare

Web Server

  1. Spring Boot API, port 8080
  2. Java NIO, port 8088

Front-end: LayUI

1. Spring Boot API

Front-end: LayUI + Vue.js

API: Json + RestController

Back-end: jMiniLang API Handler (RING 3 Process)

Screenshot 102

Back-end

import "user.base";
import "user.web";
var ctx = g_web_get_api();
if (g_is_null(ctx)) { return; }
ctx["resp"] := [
    [ "唯一标识", g_env_get_guid() ],
    [ "作者", g_author() ],
    [ "当前版本", g_version() ],
    [ "仓库地址", g_github_repo() ]
];
g_web_set_api(ctx);

2. Java NIO

Screenshot 101

import "user.base";
import "user.web";
/*
    g_web_get_context = map(code, request, response, header, mime, __ctx__)
    code* - 数字状态码, 200
    request - (headers(map), method, uri, version, protocol, url, port, host, path, query, authority)
    response* - support string, ""
    mime* - mime, application/octet-stream
    content_type* - {0: string, 1: VFS, 2: Resource, 3: File}, 0
    __ctx__ - http context
*/
var ctx = g_web_get_context();
if (g_is_null(ctx)) { return; }
if (ctx["request"]["uri"] == "/") {
    // 主页
    var html =
"
<html>
<head>
    <meta charset=\"UTF-8\">
    <link rel=\"shortcut icon\" href=\"/favicon.ico\" />
    <meta name=\"renderer\" content=\"webkit\">
    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\">
    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1\">
    <link rel=\"stylesheet\" href=\"/layui/css/layui.css\"  media=\"all\">
    <title>jMiniLang Web Server</title>
</head>
<body>
    <blockquote class=\"layui-elem-quote layui-text\">
      <p>jMiniLang 语言实现的网页服务器</p>
      <p>作者:" + g_author() + "</p>
      <p>链接:" + g_github_repo() + "</p>
      <p>前端:LayUI</p>
    </blockquote>
    <fieldset class=\"layui-elem-field layui-field-title\" style=\"margin-top: 20px; padding: 10px;\">
      <legend>请求内容</legend>
    </fieldset>
    <div class=\"layui-form\">
      <table class=\"layui-table\">
        <colgroup>
          <col width=\"100\">
          <col width=\"450\">
        </colgroup>
        <thead>
          <tr>
            <th>Key</th>
            <th>Value</th>
          </tr>
        </thead>
        <tbody>
          <tr><td>URL</td><td>" + ctx["request"]["url"]+ "</td></tr>
          <tr><td>Port</td><td>" + ctx["request"]["port"]+ "</td></tr>
          <tr><td>Host</td><td>" + ctx["request"]["host"]+ "</td></tr>
          <tr><td>Path</td><td>" + ctx["request"]["path"]+ "</td></tr>
          <tr><td>Extension</td><td>" + ctx["request"]["ext"]+ "</td></tr>
          <tr><td>Query</td><td>" + ctx["request"]["query"]+ "</td></tr>
          <tr><td>Authority</td><td>" + ctx["request"]["authority"]+ "</td></tr>
          <tr><td>User-Agent</td><td>" + ctx["request"]["headers"]["User-Agent"]+ "</td></tr>
          <tr><td>Accept</td><td>" + ctx["request"]["headers"]["Accept"]+ "</td></tr>
          <tr><td>Accept-Encoding</td><td>" + ctx["request"]["headers"]["Accept-Encoding"]+ "</td></tr>
          <tr><td>Accept-Language</td><td>" + ctx["request"]["headers"]["Accept-Language"]+ "</td></tr>
          <tr><td>Cache-Control</td><td>" + ctx["request"]["headers"]["Cache-Control"]+ "</td></tr>
          <tr><td>Connection</td><td>" + ctx["request"]["headers"]["Connection"]+ "</td></tr>
        </tbody>
      </table>
    </div>
    <script src=\"/layui/layui.js\" charset=\"utf-8\"></script>
</body>
</html>
";
    ctx["response"] := html;
    ctx["mime"] := "html-utf8";
} else {
    var ext = ctx["request"]["ext"];
    if (g_is_null(ext)) {
        ctx["code"] := 404;
    } else {
        ctx["response"] := ctx["request"]["path"];
        ctx["mime"] := ext;
        ctx["content_type"] := 2;
    }
}
g_web_set_context(ctx);

3. User mode

Screenshot 100

jMiniLisp

14 Sep 04:54
Compare
Choose a tag to compare

设计思路 - 专栏

Lisp test window

lisp

实现:ModuleLisp.txt

UI Monitor

task ui monitor on/off
task ui hitokoto on/off
task ui clock on/off

其他

解决了一堆bug。

输出方面

  • 按行输出,整行刷新。

库方面

Functional programming

09 May 23:55
Compare
Choose a tag to compare


说明

参见知乎专栏

  • 添加一言UI
  • 添加Functional模块

目前存在的问题

已在Commit 7c0b087中解决。

  • func调用g_全局函数的问题,原因是sys.func中没有import sys.string中的函数,导致找不到外部函数
  • 多重foreach中break的问题
  • xs函数中一句话代码时运行时堆栈里的问题
  • dump stack时给变量添加名称
  • 运行时报错没有详细的代码定位说明

jMiniLang OS Window

14 Apr 01:52
Compare
Choose a tag to compare




An OS running on jMiniLang interpreter.

Now has commands:

  • echo
  • dup
  • pipe
  • grep (KMP)
  • sleep
  • task
  • range

更新

Update 04/16

仿了微内核服务架构,支持退格键,去除一些BUG。仿一次系统调用相当耗时间,所以一般不使用。

Task

  1. system
    • now 获取当前时间 (v2.2.1)
  2. util
    • calc (算符优先文法)四则运算 (v2.2.2)

Add GUI Support

21 Dec 16:19
Compare
Choose a tag to compare

GUI: Use JFrame

##Features:

  • input
  • output
  • cls

MiniOS on jMiniLang

04 Dec 13:51
Compare
Choose a tag to compare

OS on script language

Like: echo foo bar | dup 2 | pipe | dup 3 | pipe

Support Multi-process

03 Sep 07:37
Compare
Choose a tag to compare

Support:

  • Pipe
  • Synchronization
  • Process

Release 1.1

27 Aug 07:17
Compare
Choose a tag to compare
  • Optimize code
  • Fix bug
  • Fix doc

Release 1.0

27 Aug 01:32
Compare
Choose a tag to compare

Usage:

java -jar jMiniLang