All Projects → WumaCoder → ctxexp-parser

WumaCoder / ctxexp-parser

Licence: MIT license
In the dynamic execution of JS language environment (wechat applet) to execute JS class calling function.

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to ctxexp-parser

eval-estree-expression
Safely evaluate JavaScript (estree) expressions, sync and async.
Stars: ✭ 22 (+29.41%)
Mutual labels:  ast, eval
Csharp Eval Unity3d
C# Expression Parser for Unity3D
Stars: ✭ 102 (+500%)
Mutual labels:  ast, eval
Asteval
minimalistic evaluator of python expression using ast module
Stars: ✭ 116 (+582.35%)
Mutual labels:  ast, eval
Python3Generator
A toolkit to generate Python 3 source code from Pharo.
Stars: ✭ 25 (+47.06%)
Mutual labels:  ast
c-compiler
A compiler that accepts any valid program written in C. It is made using Lex and Yacc. Returns a symbol table, parse tree, annotated syntax tree and intermediate code.
Stars: ✭ 37 (+117.65%)
Mutual labels:  ast
ts-transform-react-constant-elements
A TypeScript AST Transformer that can speed up reconciliation and reduce garbage collection pressure by hoisting React elements to the highest possible scope.
Stars: ✭ 44 (+158.82%)
Mutual labels:  ast
tree-hugger
A light-weight, extendable, high level, universal code parser built on top of tree-sitter
Stars: ✭ 96 (+464.71%)
Mutual labels:  ast
klara
Automatic test case generation for python and static analysis library
Stars: ✭ 250 (+1370.59%)
Mutual labels:  ast
abstract-syntax-tree
A library for working with abstract syntax trees.
Stars: ✭ 77 (+352.94%)
Mutual labels:  ast
toast
Plugin-driven CLI utility for code generation using Go source as IDL
Stars: ✭ 52 (+205.88%)
Mutual labels:  ast
predeclared
Find definitions and declarations in Go source code that shadow predeclared identifiers
Stars: ✭ 26 (+52.94%)
Mutual labels:  ast
asmdot
[Unstable] Fast, zero-copy and lightweight (Arm | Mips | x86) assembler in (C | C++ | C# | Go | Haskell | Javascript | Nim | OCaml | Python | Rust).
Stars: ✭ 23 (+35.29%)
Mutual labels:  ast
ts-transform-react-jsx-source
TypeScript AST Transformer that adds source file and line number to JSX elements
Stars: ✭ 12 (-29.41%)
Mutual labels:  ast
freAST
Fast, simple Free Monads using ScalaMeta macro annotations. Port of Freasy-Monad.
Stars: ✭ 14 (-17.65%)
Mutual labels:  ast
py2many
Transpiler of Python to many other languages
Stars: ✭ 420 (+2370.59%)
Mutual labels:  ast
robotframework-jsonvalidator
Robot Framework library for JSON validation
Stars: ✭ 21 (+23.53%)
Mutual labels:  jsonpath
clickhouse-ast-parser
AST parser and visitor for ClickHouse SQL
Stars: ✭ 60 (+252.94%)
Mutual labels:  ast
flutter ast
Flutter and Dart AST Analyzer/Parser
Stars: ✭ 87 (+411.76%)
Mutual labels:  ast
code summarization public
source code for 'Improving automatic source code summarization via deep reinforcement learning'
Stars: ✭ 71 (+317.65%)
Mutual labels:  ast
markright
A customizable markdown parser in Elixir: pure pattern matching.
Stars: ✭ 14 (-17.65%)
Mutual labels:  ast

Ctxexp Parser

上下文表达式解析器

在不能动态执行 JS 语言的环境(微信小程序)里执行类 JS 的调用函数。

Feature

  • 轻量包,未压缩 16k,压缩 4k
  • 单元测试 >85% 的代码覆盖
  • 使用状态机编写词法分析
  • 动态执行表达式
  • 调用方法支持传入 Number +1 -1 1.1
  • 调用方法支持传入 String
  • 调用方法支持传入 Callback ([参数])=><上下文表达式>
  • 支持传入多个参数
  • 支持嵌套调用
  • 语法错误检查
  • 支持链式调用、链式访问
  • 支持数组的访问

Tip

  • 不支持在表达式中使用空格 如 $.fn(1, 2)
  • 回调函数只支持简单的箭头函数

Install

npm i ctxexp-parser
# yarn add ctxexp-parser

Uses

const { CtxexpParser } = require("ctxexp-parser");
// import { CtxexpParser } from "ctxexp-parser";

const $ = {
  a: "hello",
  fn(str, str2) {
    return str + str2;
  },
  runs(...cbs) {
    return cbs.map((cb, index) => cb(index));
  },
  Type(i) {
    return ["A", "D", "C"][i];
  },
};

const exp = `$.a`;
const res = new CtxexpParser($, exp).exec();
console.log(res); // hello

const exp1 = `$.fn($.a," cxtexp")`;
const res1 = new CtxexpParser($, exp1).exec();
console.log(res1); // hello cxtexp

const exp2 = `$.runs((i)=>$.Type(i)).join("")`;
const res2 = new CtxexpParser($, exp2).exec();
console.log(res2); // A

查看更多例子

State

state

About

MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].