-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
creating template for egg-oop-parser lab
- Loading branch information
0 parents
commit b9b0181
Showing
194 changed files
with
18,098 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
node_modules/ | ||
package-lock.json | ||
please-* | ||
crguezl-egg | ||
moo-ignore | ||
egg-parser-solution | ||
docs/coverage | ||
oop-evm-releases | ||
.nyc_output | ||
bin/evm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
See <https://ull-esit-gradoii-pl.github.io/practicas/egg-parser.html> for a former description of the language | ||
|
||
Go to <https://github.com/crguezl/oop-evm-releases> to download releases of evm for mac, linux and windows that are mostly compatible with this version of the parser. Specifically here: <https://github.com/crguezl/oop-evm-releases/releases/tag/v1.1.0> | ||
|
||
See file `/src/egg.ne` to see the syntax of this version that has support for objects and methods via brackets and dots. | ||
|
||
Have a look at the `examples` folder. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
bin/eggc.js $1.egg | ||
# add in this folder the evm executable with oop extensions | ||
bin/evm $1.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env node | ||
/** | ||
* @description A executable to be able to compile eggc lang files | ||
* @author XXXX <aluXXXX@ull.edu.es> | ||
* @since XX/XX/20XX | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const {program} = require('commander'); | ||
const { parseFromFile } = require("../src/parse.js"); | ||
|
||
const {version} = require('../package.json'); | ||
|
||
/** | ||
* A function that compiles a eggc file | ||
* @param {string} origin The name of the origin file | ||
* @param {string} destination The name of the destination file | ||
* @throws Will throw if there are errors in the program or if the files | ||
* can't be opened | ||
*/ | ||
const compile = (origin, destination = undefined) => { | ||
if (destination == undefined) { | ||
destination = origin.match(/^[^\.]*/)[0] + '.json'; | ||
} | ||
|
||
const ast = parseFromFile(origin); | ||
|
||
//console.log(ast); | ||
const astString = JSON.stringify(ast, null, 2); | ||
|
||
fs.writeFileSync(destination, astString); | ||
}; | ||
|
||
program | ||
.version(version) | ||
.arguments('<origin>') | ||
.option( | ||
'-o, --out <destination>', 'Path for output file. If it isn\'t ' + | ||
'specified the path of the origin file will be used,' + | ||
'changing the extension to .json', | ||
) | ||
.description( | ||
'Compile a Egg lang file', | ||
{ | ||
origin: 'The path of the file to compile', | ||
}, | ||
) | ||
.action((origin, options) => { | ||
try { | ||
compile(origin, options.out); | ||
} catch (err) { | ||
console.log('There was an error: ' + err.message); | ||
} | ||
}); | ||
|
||
program.parse(process.argv); | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
do( | ||
def(a, [[1,2],3]), | ||
print(a.0.1) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
{ | ||
"type": "apply", | ||
"operator": { | ||
"type": "word", | ||
"line": 1, | ||
"col": 1, | ||
"length": 2, | ||
"name": "do" | ||
}, | ||
"args": [ | ||
{ | ||
"type": "apply", | ||
"operator": { | ||
"type": "word", | ||
"line": 2, | ||
"col": 5, | ||
"length": 3, | ||
"name": "def" | ||
}, | ||
"args": [ | ||
{ | ||
"type": "word", | ||
"line": 2, | ||
"col": 9, | ||
"length": 1, | ||
"name": "a" | ||
}, | ||
{ | ||
"type": "apply", | ||
"operator": { | ||
"type": "word", | ||
"length": 5, | ||
"name": "array" | ||
}, | ||
"args": [ | ||
{ | ||
"type": "apply", | ||
"operator": { | ||
"type": "word", | ||
"line": 2, | ||
"col": 14, | ||
"length": 5, | ||
"name": "array" | ||
}, | ||
"args": [ | ||
{ | ||
"type": "value", | ||
"value": 1, | ||
"line": 2, | ||
"col": 14, | ||
"length": 1 | ||
}, | ||
{ | ||
"type": "value", | ||
"value": 2, | ||
"line": 2, | ||
"col": 16, | ||
"length": 1 | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "value", | ||
"value": 3, | ||
"line": 2, | ||
"col": 19, | ||
"length": 1 | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "apply", | ||
"operator": { | ||
"type": "word", | ||
"line": 3, | ||
"col": 5, | ||
"length": 5, | ||
"name": "print" | ||
}, | ||
"args": [ | ||
{ | ||
"type": "property", | ||
"operator": { | ||
"type": "property", | ||
"operator": { | ||
"type": "word", | ||
"line": 3, | ||
"col": 11, | ||
"length": 1, | ||
"name": "a" | ||
}, | ||
"args": [ | ||
{ | ||
"type": "value", | ||
"value": "0", | ||
"line": 3, | ||
"col": 13, | ||
"length": 3, | ||
"raw": "\"0\"" | ||
} | ||
] | ||
}, | ||
"args": [ | ||
{ | ||
"type": "value", | ||
"value": "1", | ||
"line": 3, | ||
"col": 14, | ||
"length": 3, | ||
"raw": "\"1\"" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
do( | ||
def(x, array(1, array(2,3))), | ||
print(element(x,-1,4)) # Error | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
{ | ||
"type": "apply", | ||
"operator": { | ||
"type": "word", | ||
"line": 1, | ||
"col": 1, | ||
"length": 2, | ||
"name": "do" | ||
}, | ||
"args": [ | ||
{ | ||
"type": "apply", | ||
"operator": { | ||
"type": "word", | ||
"line": 2, | ||
"col": 3, | ||
"length": 3, | ||
"name": "def" | ||
}, | ||
"args": [ | ||
{ | ||
"type": "word", | ||
"line": 2, | ||
"col": 7, | ||
"length": 1, | ||
"name": "x" | ||
}, | ||
{ | ||
"type": "apply", | ||
"operator": { | ||
"type": "word", | ||
"line": 2, | ||
"col": 10, | ||
"length": 5, | ||
"name": "array" | ||
}, | ||
"args": [ | ||
{ | ||
"type": "value", | ||
"value": 1, | ||
"line": 2, | ||
"col": 16, | ||
"length": 1 | ||
}, | ||
{ | ||
"type": "apply", | ||
"operator": { | ||
"type": "word", | ||
"line": 2, | ||
"col": 19, | ||
"length": 5, | ||
"name": "array" | ||
}, | ||
"args": [ | ||
{ | ||
"type": "value", | ||
"value": 2, | ||
"line": 2, | ||
"col": 25, | ||
"length": 1 | ||
}, | ||
{ | ||
"type": "value", | ||
"value": 3, | ||
"line": 2, | ||
"col": 27, | ||
"length": 1 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "apply", | ||
"operator": { | ||
"type": "word", | ||
"line": 3, | ||
"col": 3, | ||
"length": 5, | ||
"name": "print" | ||
}, | ||
"args": [ | ||
{ | ||
"type": "apply", | ||
"operator": { | ||
"type": "word", | ||
"line": 3, | ||
"col": 9, | ||
"length": 7, | ||
"name": "element" | ||
}, | ||
"args": [ | ||
{ | ||
"type": "word", | ||
"line": 3, | ||
"col": 17, | ||
"length": 1, | ||
"name": "x" | ||
}, | ||
{ | ||
"type": "value", | ||
"value": -1, | ||
"line": 3, | ||
"col": 19, | ||
"length": 2 | ||
}, | ||
{ | ||
"type": "value", | ||
"value": 4, | ||
"line": 3, | ||
"col": 22, | ||
"length": 1 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
do( | ||
def(x, [1,4,5,7]), | ||
print(x[0]), # [1,4] | ||
print(x[1]) # 5 | ||
) |
Oops, something went wrong.