UNPKG

2.26 kBMarkdownView Raw
1# Gobstones language module for the web
2[![Build Status](https://travis-ci.org/gobstones/gs-weblang-core.svg?branch=master)](https://travis-ci.org/gobstones/gs-weblang-core)
3[![Coverage Status](https://coveralls.io/repos/github/gobstones/gs-weblang-core/badge.svg?branch=master)](https://coveralls.io/github/gobstones/gs-weblang-core?branch=master)
4[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
5[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
6[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)
7
8
9### Npm package
10
11Npm package can be found on [gs-weblang-core](https://www.npmjs.com/package/gs-weblang-core)
12
13### CDN
14
15Universal module files can be found on [unpkg](https://unpkg.com)
16For instance, version `0.1.4` can be fetched from `https://unpkg.com/gs-weblang-core@0.1.4/umd/`
17
18### Bower
19
20It can be installed with Bower too!
21```
22bower install --save gobstones/gs-weblang-core#bower
23```
24
25### Developer Tools
26
27Developer tools that include ascii board and AST viewer can be found on: `http://gobstones.github.io/gs-weblang-core/tools/index.html?v=0.1.4`
28
29Replace the version `v` with the desire version you want to try.
30
31### hello-world example
32```js
33function parseAndInterpret(sourceCode) {
34 var Context = gsWeblangCore.Context;
35 var parser = gsWebLangCore.getParser();
36
37 var ast = parser.parse(sourceCode).program;
38 return ast
39 .interpret(new Context())
40 .board();
41}
42
43// ---------
44
45parse("program { Mover(Norte)\nPoner(Azul) }");
46```
47
48### test in REPL
49
50```js
51try { require("./lib/gbs").getParser().parse(code).interpret(new (require("./lib/gbs").Context)()) } catch(e) { console.log(e) }
52```
53
54### deploy
55```bash
56git checkout master
57git pull
58git pull origin dev
59
60npm run-script build
61PACKAGE_VERSION=$(cat package.json \
62 | grep version \
63 | head -1 \
64 | awk -F: '{ print $2 }' \
65 | sed 's/[",]//g')
66PACKAGE_VERSION=$(echo $PACKAGE_VERSION | xargs)
67git add -A .
68git commit -m "Bump $PACKAGE_VERSION"
69git push
70
71git tag $PACKAGE_VERSION
72git push --tags
73
74git checkout dev
75```