Skip to content

Commit

Permalink
Merge pull request #616 from binpash/pip-libdash
Browse files Browse the repository at this point in the history
Remove `compiler/parser` subtree, use `libdash` pip module
  • Loading branch information
angelhof authored Aug 31, 2022
2 parents 132b0ab + 28968c9 commit 4910d92
Show file tree
Hide file tree
Showing 64 changed files with 51 additions and 14,598 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tight-loop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
cd evaluation/benchmarks/runtime-overhead
results=$(bash run.sh)
mkdir ~/artifact
echo "$results" > ~/artifact/results.log
echo "$results" | tee ~/artifact/results.log
- uses: actions/upload-artifact@v3
with:
name: tight-loop-artifact
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "parser/libdash"]
path = compiler/parser/libdash
url = https://github.com/angelhof/libdash/
5 changes: 4 additions & 1 deletion compiler/ast_to_ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,10 @@ def make_call_to_runtime(ir_filename, sequential_script_file_name,
## TODO: Maybe we need to only do this if there is a change.
##
set_arguments = [string_to_argument("eval"),
[['Q', string_to_argument('set -- \\"\\${pash_input_args[@]}\\"')]]]
[['Q', string_to_argument('set -- ') +
[escaped_char('"')] + # The escaped quote
string_to_argument('\\${pash_input_args[@]}') +
[escaped_char('"')]]]]
set_args_node = make_command(set_arguments)


Expand Down
4 changes: 2 additions & 2 deletions compiler/definitions/ir/file_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def to_ast(self, stdin_dash=False):
else:
raise NotImplementedError()
else:
string = "{}".format(self.resource)
argument = string_to_argument(string)
## The resource holds an Argument, and we need to get its argument list
argument = self.resource.uri.to_ast()

return argument

Expand Down
3 changes: 3 additions & 0 deletions compiler/ir_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ def string_to_argument(string):
def char_to_arg_char(char):
return ['C' , ord(char)]

def escaped_char(char):
return ['E' , ord(char)]

def standard_var_ast(string):
return make_kv("V", ["Normal", False, string, []])

Expand Down
15 changes: 7 additions & 8 deletions compiler/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,21 @@

sys.path.append(os.path.join(config.PASH_TOP, "compiler/parser/ceda"))

from ast2shell import *
from parse_to_ast2 import parse_to_ast, ParsingException
#from json_to_shell2 import json_to_shell_string, json_string_to_shell_string
import libdash.parser
import libdash.printer

## Parses straight a shell script to an AST
## through python without calling it as an executable
def parse_shell_to_asts(input_script_path):
try:
new_ast_objects = parse_to_ast(input_script_path)
new_ast_objects = libdash.parser.parse(input_script_path)
return list(new_ast_objects)
except ParsingException as e:
except libdash.parser.ParsingException as e:
log("Parsing error!", e)
sys.exit(1)

def parse_shell_to_asts_interactive(input_script_path: str):
return parse_to_ast(input_script_path)
return libdash.parser.parse(input_script_path)

def from_ast_objects_to_shell(asts):
shell_list = []
Expand All @@ -43,7 +42,7 @@ def from_ast_objects_to_shell(asts):
else:
serialized_ast = ast

shell_list.append(to_string(serialized_ast))
shell_list.append(libdash.printer.to_string(serialized_ast))
return "\n".join(shell_list) + "\n"

def from_ast_objects_to_shell_file(asts, new_shell_filename):
Expand All @@ -64,7 +63,7 @@ def parse_shell(input_script_path):

## Simply wraps the ceda string_of_arg
def pash_string_of_arg(arg, quoted=False):
return string_of_arg(arg, quoted)
return libdash.printer.string_of_arg(arg, quoted)

### Legacy

Expand Down
1 change: 0 additions & 1 deletion compiler/parser/.gitignore

This file was deleted.

50 changes: 0 additions & 50 deletions compiler/parser/Makefile

This file was deleted.

25 changes: 0 additions & 25 deletions compiler/parser/README.md

This file was deleted.

78 changes: 0 additions & 78 deletions compiler/parser/ast_atd.atd

This file was deleted.

Loading

0 comments on commit 4910d92

Please sign in to comment.