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 |
|
11 | Npm package can be found on [gs-weblang-core](https://www.npmjs.com/package/gs-weblang-core)
|
12 |
|
13 | ### CDN
|
14 |
|
15 | Universal module files can be found on [unpkg](https://unpkg.com)
|
16 | For instance, version `0.1.4` can be fetched from `https://unpkg.com/gs-weblang-core@0.1.4/umd/`
|
17 |
|
18 | ### Bower
|
19 |
|
20 | It can be installed with Bower too!
|
21 | ```
|
22 | bower install --save gobstones/gs-weblang-core#bower
|
23 | ```
|
24 |
|
25 | ### Developer Tools
|
26 |
|
27 | Developer 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 |
|
29 | Replace the version `v` with the desire version you want to try.
|
30 |
|
31 | ### hello-world example
|
32 | ```js
|
33 | function 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 |
|
45 | parse("program { Mover(Norte)\nPoner(Azul) }");
|
46 | ```
|
47 |
|
48 | ### test in REPL
|
49 |
|
50 | ```js
|
51 | try { require("./lib/gbs").getParser().parse(code).interpret(new (require("./lib/gbs").Context)()) } catch(e) { console.log(e) }
|
52 | ```
|
53 |
|
54 | ### deploy
|
55 | ```bash
|
56 | git checkout master
|
57 | git pull
|
58 | git pull origin dev
|
59 |
|
60 | npm run-script build
|
61 | PACKAGE_VERSION=$(cat package.json \
|
62 | | grep version \
|
63 | | head -1 \
|
64 | | awk -F: '{ print $2 }' \
|
65 | | sed 's/[",]//g')
|
66 | PACKAGE_VERSION=$(echo $PACKAGE_VERSION | xargs)
|
67 | git add -A .
|
68 | git commit -m "Bump $PACKAGE_VERSION"
|
69 | git push
|
70 |
|
71 | git tag $PACKAGE_VERSION
|
72 | git push --tags
|
73 |
|
74 | git checkout dev
|
75 | ```
|