Giter Site home page Giter Site logo

byshenhang / batchcommand Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dreamanlan/batchcommand

0.0 0.0 0.0 45.24 MB

一个简单的基于DSL语法的批处理和模板代码生成脚本,主要用于在Windows和Mac等不同平台上编写一个脚本进行批处理,或者用于生成代码。

Python 0.51% Lua 0.01% C# 14.18% GLSL 27.39% Batchfile 0.18% HLSL 52.19% ASL 5.55%

batchcommand's Introduction

BatchCommand

A simple batch processing and template code generation script based on DSL syntax. The main purpose is to write batch processing on different platforms such as Windows and Mac in one script, or to generate code.

deps/DslCalculator.cs is a relatively general script interpreter and implementation of common APIs. Script/BatchScript.cs is an API for batch processing, such as running another program, directory and file operations, etc. In addition, the template code generation mechanism is also implemented here, which is to embed the script again in the output text to output the program way to digitize data.

The difference between this interpreter and general interpreters is that the MetaDSL grammar abstracts the common grammatical constructs of C-like languages ​​into three types of grammar: values, functions, and statements, and then the interpreter directly hands these grammatical constructs to the API for processing. , so functions and statements are implemented by API.

Interpreter principle notes, this note is based on the previous version of MetaDSL. At that time, the basic syntax of MetaDSL had four categories: value, function call, function definition, and statement. Now there are three categories, but the principle is the same.

In addition, when BatchCommand is used for code generation, the template code generation function is often used. This is note on the relevant principles .

Because it is developed in C#, it is usually not necessary to check the source code to understand the API. It is more convenient to use ilspy to directly decompile BatchCommand.exe to check the API.

There are two main entry points for API registration. You can use ilspy to find the API from these two entries. One is DslCalculator.Init in the DslCalculator.cs file. You can see this by searching for this in ilspy:

  • Basic API registration Basic API

  • Batch processing and template replacement API registration Batch processing and template replacement API registration

There are two ways to implement the API. One is to inherit the AbstractExpression class and override the Load and DoCalc methods. The Load method has different overloaded versions corresponding to different syntax categories of MetaDSL. The main purpose here is to parse the API to prepare runtime information. DoCalc is To implement the function of the API, it is generally to calculate the parameter value, and then calculate the result based on the parameter value. The other is to inherit the SimpleExpression class and override the DoCalc method. Most APIs fall into this category. It is a function API that receives some value parameters and then calculates the results. The base class has already calculated the parameter values. In DoCalc, you only need to calculate the parameters based on the parameters. value to calculate the result.

  • class AbstractExpression api abstract class, used in all class

  • class SimpleExpression Simple function class API, used for common value parameters and return value APIs, the vast majority of APIs are of this type.

The following are simple examples of two types of APIs. Usually we click on the implemented api class in the registration section of ilspy and jump to see what parameters the API receives, what work it does, and what results it returns.

  • Simple function API example Function API implementation example

  • More complex API examples (statement APIs usually use this type of implementation, or APIs whose parameters are not ordinary value types) Other API implementation examples

Other API implementation examples

batchcommand's People

Contributors

dreamanlan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.