Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse error in gnulib-tool #573

Open
bhaible opened this issue Jun 15, 2022 · 8 comments
Open

Parse error in gnulib-tool #573

bhaible opened this issue Jun 15, 2022 · 8 comments

Comments

@bhaible
Copy link

bhaible commented Jun 15, 2022

gnulib-tool is a large shell script, from the GNU gnulib project. When I attempt to execute it through pash, with specific arguments, there is a parse error.

Here is gnulib-tool-cmp, the gnulib-tool script with an extra line 45 that sets the arguments. For successful execution, you would also need a gnulib git checkout. But pa.sh fails to parse the script, even before it gets to reading other files.

gnulib-tool-cmd.gz

$ ./pash/pa.sh gnulib-tool-cmd
Traceback (most recent call last):
  File "/home/bruno/pash/compiler/pash.py", line 262, in <module>
    main()
  File "/home/bruno/pash/compiler/pash.py", line 31, in main
    ast_objects = parse_shell_to_asts(input_script_path)
  File "/home/bruno/pash/compiler/parse.py", line 21, in parse_shell_to_asts
    return list(new_ast_objects)
  File "/home/bruno/pash/compiler/parser/ceda/parse_to_ast2.py", line 84, in parse_to_ast
    new_ast = of_node (n_ptr)
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 130, in of_node
    of_node (n.ndefun.body)]];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 141, in of_node
    return ["Redir", of_nredir (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 157, in of_nredir
    return ([n.nredir.linno, of_node (n.nredir.n), redirs (n.nredir.redirect)]);
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 124, in of_node
    of_node (n.nfor.body),
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 98, in of_node
    of_node (n.nif.ifpart),
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 98, in of_node
    of_node (n.nif.ifpart),
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 94, in of_node
    return ["Semi", of_binary (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 229, in of_binary
    return [of_node (n.nbinary.ch1), of_node (n.nbinary.ch2)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 141, in of_node
    return ["Redir", of_nredir (n)];
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 157, in of_nredir
    return ([n.nredir.linno, of_node (n.nredir.n), redirs (n.nredir.redirect)]);
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 210, in redirs
    h = mk_dup ("ToFD", n);
  File "/home/bruno/pash/compiler/parser/ceda/ast2a.py", line 182, in mk_dup
    tgt = to_arg (vname.narg);
AttributeError: 'LP_union_node' object has no attribute 'narg'

This is on an Ubuntu 22.04 machine.

@bhaible
Copy link
Author

bhaible commented Jun 15, 2022

A similar error occurs also when executing the configure script of https://ftp.gnu.org/gnu/coreutils/coreutils-9.1.tar.xz .

@angelhof
Copy link
Member

angelhof commented Jun 18, 2022

Thanks for reporting this! gnulib-tool seems to be a great stress test for PaSh.

I narrowed down the issue in gnulib-tool to the following function:

#!/bin/sh
func_emit_tests_Makefile_am ()
{
  ofd=3
  {
    echo hi
  } >&$ofd
}

Based on shellcheck's output, this (>&$ofd) doesn't look like POSIX compliant syntax.

PaSh's parser only supports POSIX compliant syntax (even though it runs scripts on bash under the hood). I don't see an immediate path for PaSh to support non-POSIX compliant syntax (that would not require significant engineering) since some of its transformations are built on the structure of the AST that is returned by a POSIX compliant dash parser reimplementation.

After finding the parsing issue I replaced $ofd with 3 (which is OK w.r.t POSIX), and now PaSh manages to parse the file, but now there are some other failures (I fixed one #575 which had to do with some file descriptors being left open but I will continue investigating).

@thesamesam
Copy link

thesamesam commented Jun 18, 2022

AFAIK most or all of gnulib is supposed to be compatible with POSIX shell so this should be fixable. Ditto configure scripts, fortunately!

@bhaible
Copy link
Author

bhaible commented Jun 18, 2022

Thanks for trimming that down to a small test case; I would not have known how to do that.

Based on shellcheck's output, this (>&$ofd) doesn't look like POSIX compliant syntax.

I think it is POSIX compliant syntax, and shellcheck's warning is a bug: koalaman/shellcheck#2520

Additionally, for this slightly modified shell script

#!/bin/sh
func_emit_tests_Makefile_am ()
{
  ofd=3
  {
    echo hi
  } 1>&$ofd
}
func_emit_tests_Makefile_am 3>&1

for which pa.sh fails to parse in the same way, shellcheck does not give a warning.

@angelhof
Copy link
Member

Thanks for checking this! By the way, I only mentioned shellcheck as evidence that this is not POSIX compliant (I am not sure if we can trust it for absolute precision, it probably has both false positives and false negatives).

We will investigate the parsing issue. At the same time, we will investigate the more important failures that happen once the script is parsed :)

@bhaible
Copy link
Author

bhaible commented Jun 19, 2022

we will investigate the more important failures that happen once the script is parsed :)

When you get to this stage, you'll need a GNU gnulib checkout (see https://savannah.gnu.org/git/?group=gnulib ) and put the script into the top-level directory of that checkout (so that it finds the various input files).

@mgree
Copy link
Collaborator

mgree commented Jun 22, 2022

I can confirm that the POSIX spec allows this behavior, and dash accepts it:

$ fd=2
$ echo hi >&$fd
hi
$ fd=3
$ echo hi >&$fd
/Users/mgree/smoosh/libdash/src/dash: 4: 3: Bad file descriptor

Smoosh works as well, using the OCaml version of our bindings:

$ fd=2
$ echo hi >&$fd
hi
$ fd=3 
$ echo hi >&$fd
Bad file descriptor: 3

So I suspect there's a bug somewhere in our Python bindings or in our handling of the resulting AST.

@angelhof
Copy link
Member

Thanks @mgree, I fixed it in this PR ( #582 ) actually! This was an untested corner of the parser and it needed one extra dereference.

There are still issues with the gnulib-tool which require investigation but parsing seems to pass now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants