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.
I would greatly appreciate input on the tree as well as insight into
missing functionality you might see.
Thanks,
Nathan Eloe
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkxG+tAACgkQFpoRlVgtqKYoRgCfUXxQBBY9J2 zixrthtaRK+Yej
NesAnR5/69t68J/nlswiw6LEvXebUENi
=MuDw
-----END PGP SIGNATURE-----
#!/bin/bash
# A "featureful" script that demonstrates all the functionality of the parser
#############################################
#Copyright 2010 Nathan Eloe
#
#This file is part of libbash.
#
#libbash is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 2 of the License, or
#(at your option) any later version.
#
#libbash is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with libbash. If not, see <http://www.gnu.org/licenses/>.
##############################################
#comment
#demonstrates expansions in strings both double- and non-quoted
function lots_o_echo() {
echo "The number of tests that have failed: $failedtests"
echo '$failedtests'
echo $failedtests
}
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 abc"def
# Escape sequences like ..
echo "abc"def"
# Invocation from ibnside strings
echo "foo $(echo foo), bar `echo bar`"
# 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
07-21-2010, 04:25 PM
Nathan Eloe
Google Summer of Code: Bash AST and grammar
-----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 abc"def
>>
>> # 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/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/