Skip to content
/ CoLI Public

Computer Language Interface. A Code builder (json, jsx, js, ts, dart, css, xml, html, python) AST Builder / Parser

License

Notifications You must be signed in to change notification settings

gridaco/CoLI

Repository files navigation

CoLI

Computer Language Interface (node, dart, css, html, python) An AST Builder / Parser

design file available here

Installation

yarn add coli

Supported platforms

  • NodeJS

Builders

Read BUILDERS.md

Supported gen target languages

  • JSX / TSX
  • JS / TS
  • Dart (+ Flutter)
  • CSS
  • SCSS
  • XML
  • HTML

CoLI Node implementation.

jsx building

div(div("content"))

>>> <div>
>>>   <div>
>>>     content
>>>   </div>
>>> </div>

dart variable declaration

const file = new File("main.dart")
file.add(Variable.const("someVariable", "hi there!", CoLITypes.String))

// main.dart
>>> final String someVariable = "hi there!";

to check work around for generating flutter code - checkout @flutter-builder

Function

build function with coli syntax

// 1.

function thisIsNativeFunction() {}

const coliFunc = coli.function(thisIsNativeFunction);

coliFunc.toDart();
// > void thisIsNativeFunction(){}
coliFunc.toPython({ followConvention: true });
// > def this_is_native_function(): ...
coliFunc.toJavascript();
// > function thisIsNativeFunction(){}

// 2.
const coliFunc = new coli.Function({
  returns: coli.Types.void,
  name: "thisIsGeneratedFunction",
  params: {
    first: {
      required: false,
      type: coli.Types.any,
    },
  },
  executable: coli.Executable.fromStatic("console.log('hi there.');"),
});
coliFunc.toJavascript();
// > function thisIsGeneratedFunction(first){ console.log('hi there.'); }

Development

# packs the workspace
yarn
# runs the editor webapp
yarn editor

Building - coli use lerna to build packages. running yarn build will build individual packages.

yarn build

References

About

Computer Language Interface. A Code builder (json, jsx, js, ts, dart, css, xml, html, python) AST Builder / Parser

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages