eolang 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.0pdd.yml ADDED
@@ -0,0 +1,9 @@
1
+ errors:
2
+ - yegor256@gmail.com
3
+ # alerts:
4
+ # github:
5
+ # - yegor256
6
+
7
+ tags:
8
+ - pdd
9
+ - bug
package/.eslintrc.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "env": {
3
+ "es6": true
4
+ },
5
+ "extends": "google",
6
+ "rules": {
7
+ "indent": "off"
8
+ }
9
+ }
package/.gitattributes ADDED
@@ -0,0 +1,9 @@
1
+ # Check out all text files in UNIX format, with LF as end of line
2
+ # Don't change this file. If you have any ideas about it, please
3
+ # submit a separate issue about it and we'll discuss.
4
+
5
+ * text=auto eol=lf
6
+ *.rb ident
7
+ *.xml ident
8
+ *.png binary
9
+ *.pdf binary
@@ -0,0 +1,17 @@
1
+ name: grunt
2
+ on:
3
+ push:
4
+ pull_request:
5
+ concurrency:
6
+ group: ${{ github.ref }}
7
+ cancel-in-progress: true
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ - uses: actions/setup-node@v1
14
+ with:
15
+ node-version: ${{ matrix.node-version }}
16
+ - run: npm ci
17
+ - run: grunt
package/.pdd ADDED
@@ -0,0 +1,8 @@
1
+ --source=.
2
+ --verbose
3
+ --exclude target/**/*
4
+ --exclude coverage/**/*
5
+ --exclude node_modules/**/*
6
+ --rule min-words:20
7
+ --rule min-estimate:15
8
+ --rule max-estimate:90
package/.rultor.yml ADDED
@@ -0,0 +1,25 @@
1
+ assets:
2
+ npmrc: objectionary/secrets#npmrc
3
+ install: |
4
+ pip install git+https://chromium.googlesource.com/external/gyp
5
+ npm install --no-color --include dev
6
+ sudo npm install --no-color --global grunt-cli
7
+ npm uninstall --no-color grunt-cli
8
+ npm install --no-color mocha
9
+ pdd -f /dev/null -v
10
+ release:
11
+ script: |
12
+ [[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit -1
13
+ sed -i -e "s/^\"version\": \"0.0.0\"/\"version\": \"${tag}\"/" package.json
14
+ sed -i -e "s/^0.0.0/${tag}/" src/version.js
15
+ grunt --no-color
16
+ git commit -am "set version to ${tag}"
17
+ chmod 600 ../npmrc
18
+ npm publish --no-color --userconfig=../npmrc
19
+ merge:
20
+ script: |-
21
+ grunt --no-color
22
+ deploy:
23
+ script: |-
24
+ echo "There is nothing to deploy"
25
+ exit -1
package/Gruntfile.js ADDED
@@ -0,0 +1,57 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2022 Yegor Bugayenko
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included
14
+ * in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ module.exports = function(grunt) {
26
+ grunt.initConfig({
27
+ pkg: grunt.file.readJSON('package.json'),
28
+ clean: ['coverage'],
29
+ mochaTest: {
30
+ test: {
31
+ options: {
32
+ reporter: 'spec',
33
+ require: 'blanket',
34
+ },
35
+ src: ['test/**/*.js'],
36
+ },
37
+ coverage: {
38
+ options: {
39
+ reporter: 'mochawesome',
40
+ // quiet: true,
41
+ captureFile: 'coverage.html',
42
+ },
43
+ src: ['test/**/*.js'],
44
+ },
45
+ },
46
+ eslint: {
47
+ options: {
48
+ configFile: '.eslintrc.json',
49
+ },
50
+ target: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
51
+ },
52
+ });
53
+ grunt.loadNpmTasks('grunt-eslint');
54
+ grunt.loadNpmTasks('grunt-mocha-test');
55
+ grunt.loadNpmTasks('grunt-contrib-clean');
56
+ grunt.registerTask('default', ['mochaTest', 'eslint']);
57
+ };
package/LICENSE.txt ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2022 Yegor Bugayenko
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included
11
+ in all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,38 @@
1
+ <img alt="logo" src="https://www.objectionary.com/cactus.svg" height="100px" />
2
+
3
+ [![grunt](https://github.com/objectionary/eoc/actions/workflows/grunt.yml/badge.svg)](https://github.com/objectionary/eoc/actions/workflows/grunt.yml)
4
+
5
+ First, you install [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).
6
+
7
+ Then, you install [eolang](...) package:
8
+
9
+ ```
10
+ $ npm install eolang
11
+ ```
12
+
13
+ Then, you write a [EO](https://www.eolang.org) program in a few `.eo` files
14
+ in the current directory.
15
+
16
+ Then, for example, you compile it to Java and run:
17
+
18
+ ```
19
+ $ eoc run
20
+ ```
21
+
22
+ That's it.
23
+
24
+ You can also do many other things with `eoc` commands:
25
+
26
+ * `parse` converts EO program to XMIR files
27
+ * `optimize` reorganizes XMIR files and prepares them for transpilation
28
+ * `translate` converts Java/C++/Python/etc. program to EO program
29
+ * `demu` removes `cage` and `memory` objects
30
+ * `dejump` removes `goto` objects
31
+ * `infer` suggests object names where it's possible to infer them
32
+ * `flatten` moves inner objects to upper level
33
+ * `transpile` converts XMIR to target programming language
34
+ * `compile` converts target language to binaries
35
+ * `run` executes the binaries
36
+
37
+ This command line toolkit simply integrates other tools available in
38
+ [@objectionary](https://github.com/objectionary) GitHub organization.
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "eolang",
3
+ "version": "0.0.0",
4
+ "author": "Yegor Bugayenko",
5
+ "license": "MIT",
6
+ "repository": "objectionary/eoc",
7
+ "bin": {
8
+ "eoc": "./src/eoc.js"
9
+ },
10
+ "devDependencies": {
11
+ "blanket": "1.2.3",
12
+ "commander": "9.2.0",
13
+ "eslint": "5.15.3",
14
+ "eslint-config-google": "0.12.0",
15
+ "grunt": "^1.5.3",
16
+ "grunt-contrib-clean": "2.0.0",
17
+ "grunt-eslint": "21.0.0",
18
+ "grunt-mocha-test": "0.13.3",
19
+ "mocha": "^10.0.0",
20
+ "mochawesome": "7.1.3"
21
+ },
22
+ "dependencies": {
23
+ "dev": "^0.1.3"
24
+ }
25
+ }
package/src/eoc.js ADDED
@@ -0,0 +1,57 @@
1
+ #! /usr/bin/env node
2
+ /*
3
+ * The MIT License (MIT)
4
+ *
5
+ * Copyright (c) 2022 Yegor Bugayenko
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included
15
+ * in all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
26
+ const exec = require('child_process').exec;
27
+
28
+ const {Command} = require('commander');
29
+ const program = new Command();
30
+
31
+ program
32
+ .name('eoc')
33
+ .description('EO command-line toolkit')
34
+ .version(require('./version'));
35
+
36
+ program
37
+ .option('-s, --sources <path>')
38
+ .option('-t, --target <path>');
39
+
40
+ program.command('parse')
41
+ .description('parse EO source code into XMIR')
42
+ // .argument('<test>', 'test argument')
43
+ // .option('--a', 'test text')
44
+ .option('-b, --bbb <char>', 'test text', ',')
45
+ .action((str, options) => {
46
+ exec('echo BOOM', function(error, stdout, stderr) {
47
+ console.log('stdout: ' + stdout);
48
+ console.log('stderr: ' + stderr);
49
+ if (error !== null) {
50
+ console.log('exec error: ' + error);
51
+ }
52
+ });
53
+ console.log(program.opts());
54
+ console.log('hello, world!');
55
+ });
56
+
57
+ program.parse();
package/src/version.js ADDED
@@ -0,0 +1,26 @@
1
+ #! /usr/bin/env node
2
+ /*
3
+ * The MIT License (MIT)
4
+ *
5
+ * Copyright (c) 2022 Yegor Bugayenko
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included
15
+ * in all copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
26
+ module.exports = '0.0.0';
@@ -0,0 +1,61 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2022 Yegor Bugayenko
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included
14
+ * in all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ /**
26
+ * Helper to run EOC command line tool.
27
+ *
28
+ * @param {Array} args - Array of args
29
+ * @param {Function} fn - Callback
30
+ * @return {Mixed} The result of exec()
31
+ */
32
+ function eoc(args, fn) {
33
+ const path = require('path');
34
+ const exec = require('child_process').exec;
35
+ return exec(
36
+ `node ${path.resolve('./src/eoc.js')} ${args.join(' ')}`,
37
+ (error, stdout, stderr) => {
38
+ assert.equal(null, error);
39
+ assert.equal('', stderr);
40
+ return fn(stdout);
41
+ }
42
+ );
43
+ }
44
+
45
+ const assert = require('assert');
46
+
47
+ describe('eoc', function() {
48
+ it('prints its own version', function(done) {
49
+ eoc(['--version'], function(stdout) {
50
+ assert.equal(require('../src/version.js') + '\n', stdout);
51
+ done();
52
+ });
53
+ });
54
+
55
+ it('prints help screen', function(done) {
56
+ eoc(['--help'], function(stdout) {
57
+ assert(stdout.includes('Usage: eoc'));
58
+ done();
59
+ });
60
+ });
61
+ });