Re: [gentoo-portage-dev] Google Summer of Code: Bash AST and grammar

2010-07-21 Thread Sebastian Pipping

On 07/21/10 15:49, Nathan Eloe wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello portage developers

My name is Nathan Eloe, and I'm working on a Google Summer of Code
project in which I'm writing a library that will create an Abstract
Syntax Tree of the bash grammar.  In essence I am recreating the bash
grammar and structuring it as an AST.

I am writing to you because you have shown interest in
this project.  I have attached a bash script which demonstrates the
supported functionality of the grammar thus far and the resulting AST.


Nice, you have covered quite a few constructs alraedy.



I would greatly appreciate input on the tree


I'm unsure if such a big file and tree is good to handle.
I propose to split this test suite to many small cases.



as well as insight into
missing functionality you might see.


A few things I haven't seen, yet:

  # Adjacent changes in quotation
  echo abc''def  # Makes abcdef

  # Escape sequences like ..
  echo abc\def

  # Invocation from ibnside strings
  echo foo $(echo foo), bar `echo bar`

  # Heredocs (and their variations ..)
  cat EOF /dev/stdout
  1
  2
  EOF

  # Construct of $((..))
  # Refs to variable withzout $ upfront
  z=3; echo $((z+3))

Best,



Sebastian



Re: [gentoo-portage-dev] Google Summer of Code: Bash AST and grammar

2010-07-21 Thread Sebastian Pipping

On 07/21/10 16:56, Sebastian Pipping wrote:

A few things I haven't seen, yet:

# Adjacent changes in quotation
echo abc''def # Makes abcdef

# Escape sequences like ..
echo abc\def

# Invocation from ibnside strings
echo foo $(echo foo), bar `echo bar`

# Heredocs (and their variations ..)
cat EOF /dev/stdout
1
2
EOF

# Construct of $((..))
# Refs to variable withzout $ upfront
z=3; echo $((z+3))


An important one I forgot:

  # Line continuation
  echo one \
two

Potentially hase quite a few sub cases ..

Best,



Sebastian



Re: [gentoo-portage-dev] Google Summer of Code: Bash AST and grammar

2010-07-21 Thread Nathan Eloe
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 7/21/10 10:25 AM, Sebastian Pipping wrote:
 On 07/21/10 16:56, Sebastian Pipping wrote:
 A few things I haven't seen, yet:

 # Adjacent changes in quotation
 echo abc''def # Makes abcdef

 # Escape sequences like ..
 echo abc\def

 # Invocation from ibnside strings
 echo foo $(echo foo), bar `echo bar`

I'll test those, though I think the only one that I haven't even thought
about was the escape sequences

 # Heredocs (and their variations ..)
 cat EOF /dev/stdout
 1
 2
 EOF


Heredocs/strings are... present but broken.  The problem is they just
consume strings like crazy.  Perhaps with some semantic predicates I can
get it to stop at the end.  For now though it would just keep consuming
till the end of the file

 # Construct of $((..))
 # Refs to variable withzout $ upfront
 z=3; echo $((z+3))
 
 An important one I forgot:
 
   # Line continuation
   echo one \
 two
 

Both of these have yet to be implemented, though doing so should be trivial.

Thanks for the input!  Any and all input I can get is helpful.

Nathan
-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkxHH5MACgkQFpoRlVgtqKbnfwCbBdgYaqZfSLxa7GTgrtV1wZfg
e94An3HkOPUE6BVQ1YsyeogJ92ZsRK6z
=5ezP
-END PGP SIGNATURE-