Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

rapid-d9t/rapid-cds-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rapid CDS Parser

ci Hits-of-Code codecov

npm module for rapid parsing of cds written in rust as component of rapidcds extention

Installing

Installing of rapid-cds-parser requires a supported version of Node and Rust.

You can install the project with npm. In the project directory, run:

$ npm install

This fully installs the project, including installing any dependencies and running the build.

Building

If you have already installed the project and only want to run the build, run:

$ npm run build

This command uses the cargo-cp-artifact utility to run the Rust build and copy the built library into ./index.node.

Exploring rapid-cds-parser

After building rapid-cds-parser, you can explore its exports at the Node REPL:

$ npm install
$ node
> require('.').generateIR('test.cds')
{
  types: [],
  entities: [
    {
      name: 'Test',
      aspects: [],
      isProjection: false,
      fields: [
        {
          name: 'field',
          hasDefault: false,
          type: 'TestType',
        },
      ],
    },
  ],
  services: [
    {
      actions: [
        {
          name: 'actionName',
          hasOutput: true,
          output: {
            type: 'Test',
            isArrayed: true,
          },
          params: [
            {
              type: 'Test',
              isArrayed: false,
              name: 'arg1',
            },
          ],
        },
      ],
      name: 'TestService',
      entities: [
      ],
      functions: [
        {
          output: {
            isArrayed: false,
            type: 'OutputType',
          },
          params: [],
          name: 'functionName',
        },
      ],
    },
  ],
}

Available Scripts

In the project directory, you can run:

npm install

Installs the project, including running npm run build.

npm build

Builds the Node addon (index.node) from source.

npm test

Runs the unit tests by calling cargo test. You can learn more about adding tests to your Rust code from the Rust book.

Project Layout

The directory structure of this project is:

rapid-cds-parser/
├── Cargo.toml
├── README.md
├── lib.node
├── index.js
├── package.json
├── src/
|   └── lib.rs
|   └── parser/
|   └── ir/
├── tests/
└── target/

Cargo.toml

The Cargo manifest file, which informs the cargo command.

README.md

This file.

lib.node

The Node addon—i.e., a binary Node module—generated by building the project. Under the hood, a Node addon is a dynamically-linked shared object. The "build" script produces this file by copying it from within the target/ directory, which is where the Rust build produces the shared object.

index.js

The wrapper around lib.node to make it usable in modern IDEs. This is the main module for this package, as dictated by the "main" key in package.json.

package.json

The npm manifest file, which informs the npm command.

src/

The directory tree containing the Rust source code for the project.

src/parser/

Implementation of a cds languages parser with lalrpop.

src/ir/

Implementation of intermediate representation generation from the AST parser produces.

src/lib.rs

The Rust library's main module.

tests/

Implementation of library's integration tests.

target/

Binary artifacts generated by the Rust build.