mirror of
https://github.com/fluencelabs/aqua.git
synced 2024-12-04 22:50:18 +00:00
Initial
This commit is contained in:
parent
6cc3a969d2
commit
3d238fe475
2
.gitignore
vendored
2
.gitignore
vendored
@ -11,3 +11,5 @@ project/target
|
||||
|
||||
npm/aqua.js
|
||||
**/node_modules
|
||||
|
||||
**/.antlr
|
||||
|
51
fuzzing-tests/Aqua.g4
Normal file
51
fuzzing-tests/Aqua.g4
Normal file
@ -0,0 +1,51 @@
|
||||
grammar Aqua;
|
||||
|
||||
tokens {
|
||||
INDENT,
|
||||
DEDENT,
|
||||
NL
|
||||
}
|
||||
|
||||
@lexer::members {
|
||||
# A hack to support indentation
|
||||
def create_node(self, node, *args, **kwargs):
|
||||
result = super().create_node(node, *args, **kwargs)
|
||||
|
||||
if not hasattr(self, "indent_level"):
|
||||
self.indent_level = 0
|
||||
|
||||
if node.name == "INDENT":
|
||||
self.indent_level += 1
|
||||
result.src = "\n" + " " * self.indent_level
|
||||
elif node.name == "DEDENT":
|
||||
self.indent_level -= 1
|
||||
result.src = "\n" + " " * self.indent_level
|
||||
elif node.name == "NL":
|
||||
result.src = "\n" + " " * self.indent_level
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
prog: function+;
|
||||
|
||||
function: FUNC SP+ closure;
|
||||
|
||||
closure:
|
||||
ID LPAREN ((typedId COMMA SP*)* typedId)? RPAREN COLON block;
|
||||
|
||||
block: INDENT ('expr' NL | ifStat)+ DEDENT;
|
||||
|
||||
ifStat: IF SP+ ID COLON block;
|
||||
|
||||
typedId: ID SP* COLON SP* type;
|
||||
|
||||
type: 'u16';
|
||||
|
||||
LPAREN: '(';
|
||||
RPAREN: ')';
|
||||
COLON: ':';
|
||||
COMMA: ',';
|
||||
SP: ' ';
|
||||
IF: 'if';
|
||||
FUNC: 'func';
|
||||
ID: [a-zA-Z][a-zA-Z_]+;
|
21
fuzzing-tests/README.md
Normal file
21
fuzzing-tests/README.md
Normal file
@ -0,0 +1,21 @@
|
||||
# Fuzzing tests for Aqua Compiler
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
python3 -m pip install -r requirements.txt
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
File `Aqua.g4` contains ANTLRv4 grammar of Aqua Language.
|
||||
|
||||
The following command will generate python fuzzing input generators for Aqua in `generated` dir:
|
||||
```sh
|
||||
grammarinator-process Aqua.g4 -o generated
|
||||
```
|
||||
|
||||
The following command will generate `N` tests in `tests` dir with maximum grammar depth `D`:
|
||||
```sh
|
||||
grammarinator-generate -p generated/AquaUnparser.py -l generated/AquaUnlexer -r prog -n N -d D
|
||||
```
|
1
fuzzing-tests/requirements.txt
Normal file
1
fuzzing-tests/requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
grammarinator==19.3
|
Loading…
Reference in New Issue
Block a user