zExpression syntax compiler + interpreter, script engine kernel
Technical system explanation:
- In the technical system of compilation principle, preprocessing is required before processing textual code. The syntax and syntax sugar we often talk about are all preprocessing programs
- Lexical method: Lexical method is to classify text keywords, numbers, and symbols, and finally form a lexical tree, and strictly follow the principle of sequential processing.
- Statement: In the preprocessing code, the declaration part is called the declaration tree. The declaration tree also relies on lexical sequential preprocessing, because lexical preprocessing is a simplified method.
- Syntax: After declaration preprocessing, it processes the single-line logical operations of code expressions. This step is called syntax. It is taken as zExpression syntax compiler. It is a solution I deliberately stripped out from the compiler I once wrote. It can be distributed and used independently, and can be practically used in digital preprocessing, graphics images, scientific computing and other fields, and can also be used as a means to learn to improve oneself.
Core idea
- Implementing zExpression adopts the principle of peer-to-peer complexity and is written to solve compiler problems. The complexity is much higher than that of regular programs. Because it solves the final problem, there are no vulnerabilities in the naming and heap structure of the code, so it is a mature syntactic interpreter solution.
Features of zExpression
- Complete single-step atomization operation
- Complete symbol priority post-processing
- Can preprocess literal errors and feedback where the error occurs
- Natural number writing method that can identify floating points and integers
- Support function calls
- Support custom script syntax
- Inverse Poland 2.0 Symbol Priority Processing
- Supports Android and Apple models of mobile phones
- Complete functional demo, complete performance and parsing accuracy evaluation framework
- After compilation, atomized op code can be formed, which can be loaded and run at high speed through stream without restricting the CPU type
- OP code framework can be easily decoded into machine codes for ARMv7 ARMx64 x64 x86 and other platforms
- Matrix and vector expression support
Platform support, test with Delphi 10.3 update 2 and FPC 3.0.4
- Windows: delphi-CrossSocket(C/S OK), delphi-DIOCP(C/S OK), delphi-ICS(C/S OK), delphi-Indy(C/S OK), delphi+fpc Synapse(C/S OK)
- Android:Indy(C/S OK), CrossSocket(Only Client)
- IOS Device: Indy(C/S OK), CrossSocket(Only Client)
- IOS Simulaor: n/a
- OSX: Indy(C/S OK), ICS(not tested), CrossSocket(C/S OK)
- Ubuntu16.04 x64 server: Indy(C/S OK), CrossSocket(C/S OK)
- Ubuntu18.04 x86+x64 Desktop: only fpc3.0.4 Synapse(C/S OK)
- Ubuntu18.04 x86+x64 Server:only fpc3.0.4 Synapse(C/S OK)
- Ubuntu18.04 arm32+arm neon Server:only fpc3.0.4 Synapse(C/S OK)
- Ubuntu18.04 arm32+arm neon desktop:only fpc3.0.4 compile ok,no test on run.
- Ubuntu16.04 Mate arm32 desktop:only fpc3.0.4 compile ok, test passed
- Raspberry Pi 3 Debian linux armv7 desktop, only fpc 3.0.4, test passed.
- wince(arm eatbi hard flat),windows 10 IOT, only fpc 3.3.1,test passed.
CPU architecture support, test with Delphi 10.3 update 2 and FPC 3.0.4
- MIPS(fpc-little endian), soft float, test pass on QEMU
- Intel X86(fpc-x86), soft float
- Intel X86(delphi+fpc), hard float,80386,PENTIUM,PENTIUM2,PENTIUM3,PENTIUM4,PENTIUMM,COREI,COREAVX,COREAVX2
- Intel X64(fpc-x86_64), soft float
- Intel X64(delphi+fpc), hard float,ATHLON64,COREI,COREAVX,COREAVX2
- ARM(fpc-arm32-eabi,soft float):ARMV3,ARMV4,ARMV4T,ARMV5,ARMV5T,ARMV5TE,ARMV5TEJ
- ARM(fpc-arm32-eabi, hard float): ARMV6, ARMV6K, ARMV6T2, ARMV6Z, ARMV6M, ARMV7, ARMV7A, ARMV7R, ARMV7M, ARMV7EM
- ARM(fpc-arm64-eabi, hard float):ARMV8, aarch64
Update log
2021-9-22
- The NumberBase library has built-in zExpression driver. For details, please refer to zCloud's network variable service https://github.com/PassByYou888/zCloud
- Fixed the issue where OpCache was not initialized
- Optimize OpRunTime
- Support delphi 11
- Support fpc for IOT devices
2021-7
- Fixed recognition problems such as character expression-2.0E-3
- Fixed the OpCode.pas library because of case sensitivity and incompatible with win/linux
2020-3
- Added declaration information to the registration function
- Fix the pre-function symbol -func(1+1)
- Fixed the symbol func(1+1)-1 after function
2019-7
Matrix expression support
// 构建3*3的variant矩阵,使用c语法表达式
procedure MatrixExp ;
var
m: TExpressionValueMatrix;
begin
DoStatus( ' ' );
m := EvaluateExpressionMatrix( 3 , 3 ,
' "hello"+"-baby"/*备注:字符串联合*/,true,false, ' +
' 1+1,2+2,3+3, ' +
' 4*4,4*5,4*6 ' , tsC);
DoStatus(m);
end ;
// 构建variant向量数组,使用pascal语法表达式
procedure MatrixVec ;
var
v: TExpressionValueVector;
begin
DoStatus( ' ' );
v := EvaluateExpressionVector( ' 0.1*(0.1+max(0.15,0.11)){备注内容},1,2,3,4,5,6,7,8,9 ' , tsPascal);
DoStatus(v);
end ; 2019-4
- Fixed the bug after TextParsing notes encoding
- OpCode adds callback type (refer to Script support in the zAI toolchain)
2018-9-29
- New technology: Added text probe technology: can reduce the programming complexity of Ant programs by 50%.
- New technology: Character-by-character text character crawling performance improves %500
- Multi-platform: Fully support for multiple IoT systems and multi-processor hardware architectures
- New Demo: Added a new FPC demo, which does not use anonymous functions
- Process: Compatible with IOT support based on FPC: From the underlying to the advanced, large-scale unified naming is adjusted and naming. This adjustment will affect the code details of many projects.
// 本项目中的回调分为3种
// call: 直接指针回调,fpc+delphi有效
// method: 方法回调,会继承一个方法宿主的地址,fpc+delphi有效
// proc: 匿名过程回调,只有delphi有效
// 如果本项调整对于改造现有工程有一定的工作量,请使用字符串批量处理工具
// 在任何有回调重载的地方,方法与函数,均需要在后缀曾加回调类型首字母说明
// 如
RunOp 变更为 RunOpP() // 后缀加P表示匿名类型回调
RunOp 变更为 RunOpM() // 后缀加M表示方法类型的回调
RunOp 变更为 RunOpC() // 后缀加C表示指针类型的回调
2018-7-6
- Significantly correct the naming rules of the underlying library
- Supports the fpc/86/64 platform, and all basic libraries support trouble-free compilation and operation under Linux.
- Full support for fpc compiler 3.1.1
- Added size and endian support
- Fixed the issue of not refusing to use Int64 for 32-bit FPC compiler
- Fixed the problem of exceptions in strings running on Linux when fpc compiler
- Added pascal precompilation tool to standardize pascal code into C-style all unified case, which is fully compatible with Linux case-sensitive file names mechanism
2018-4-12
- Fixed a memory out-of-bounds bug in the kernel: The symptom of this bug is that it is inaccessible for no reason, and it is difficult to eliminate through normal debugging. This is a bug caused by memory out-of-bounds.
2018-3-1
- Added a fuzzy string comparison function (SmithWaterman) to the TPascalString kernel, optimization and testing are completed
- This algorithm belongs to the Wikipedia address of Smith-Waterman, a discipline of biological genetic engineering. https://en.wikipedia.org/wiki/Smith%E2%80%93Waterman_algorithm
2018-2-28
- Fix c escape character buf, thanks to Amu qq345148965
- Change the parameter naming of charPos to cOffset and add a const modifier
2018-2-26
- Fixed the problem of not being able to compile using Release mode
- Fixed the problem of incorrect cutting and segmentation in zExpression
- Slightly improve the cutting performance of character probes (splitToken, splitChar)
- Because the underlying layer rewrites an atomic lock, the packed modifier is added before many record declarations
2018-2-25
- Added custom expression symbol support
- New demonstration of custom expression symbols
2018-2-25
- Fixed the problem that nested function parameters cannot expand the interface correctly
- Fixed the problem that the analysis engine's digital probe cannot recognize hexadecimal natural numbers and functions
- Added a new demo example for assignment, including variable declaration, static multiplexing, dynamic multiplexing, a total of trilogies. Please study it yourself in the example demonstration.
- Fixed the issue of string and number matching union
- Supports C code style 0x16-digit syntax
2018-2-6
- Rewrite the parser kernel once, supports function calls, and from now on, zExpression will be updated continuously
If you have any questions about using zExpression, please add the mutual aid qq group 490269542, please do not contact the author directly
by.qq600585 2017-6