-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use Test::More tests => 2; | ||
|
||
use MarpaX::Languages::Bash::AST; | ||
my $grammar = MarpaX::Languages::Bash::AST->new(); | ||
|
||
my $value_ref; | ||
|
||
$value_ref = $grammar->parse( \(<<'EOI') ); | ||
a=42 * 1 + 7 | ||
EOI | ||
|
||
is_deeply $value_ref, \[ ['assignment', 'a', '42 * 1 + 7' ] ]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use Test::More tests => 5; | ||
|
||
use MarpaX::Languages::Bash::AST; | ||
my $grammar = MarpaX::Languages::Bash::AST->new(); | ||
|
||
my $value_ref; | ||
|
||
$value_ref = $grammar->parse( \(<<'EOI') ); | ||
42 * 1 + 7 # Add one and seven, multiply by fourty-two | ||
EOI | ||
|
||
is_deeply $value_ref, \[ 42 * 1 + 7, ['comment', ' Add one and seven, multiply by fourty-two'] ]; | ||
|
||
$value_ref = $grammar->parse( \(<<'EOI') ); | ||
42 * 1 + 7 | ||
# Add one and seven, multiply by fourty-two | ||
EOI | ||
|
||
is_deeply $value_ref, \[ 42 * 1 + 7, ['comment', ' Add one and seven, multiply by fourty-two'] ]; | ||
|
||
$value_ref = $grammar->parse( \(<<'EOI') ); | ||
42 * 1 + 7 # Add one and seven, multiply by fourty-two | ||
EOI | ||
|
||
is_deeply $value_ref, \[ 42 * 1 + 7, ['comment', ' Add one and seven, multiply by fourty-two'] ]; | ||
|
||
$value_ref = $grammar->parse( \(<<'EOI') ); | ||
# Add one and seven, multiply by fourty-two | ||
42 * 1 + 7 | ||
EOI | ||
|
||
is_deeply $value_ref, \[ ['comment', ' Add one and seven, multiply by fourty-two'], 42 * 1 + 7 ]; | ||
|
||
$value_ref = $grammar->parse( \(<<'EOI') ); | ||
# Add one and seven, multiply by fourty-two | ||
42 * 1 + 7 | ||
EOI | ||
|
||
is_deeply $value_ref, \[ ['comment', ' Add one and seven, multiply by fourty-two'], 42 * 1 + 7 ]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use Test::More tests => 1; | ||
|
||
use MarpaX::Languages::Bash::AST; | ||
my $grammar = MarpaX::Languages::Bash::AST->new(); | ||
|
||
my $value_ref; | ||
|
||
my $input = <<'EOI'; | ||
42 * 1 + 7 | ||
42 * 1 + 7 | ||
EOI | ||
chomp $input; | ||
$value_ref = $grammar->parse( \$input ); | ||
|
||
is_deeply $value_ref, \[ 42 * 1 + 7, 42 * 1 + 7 ]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use Test::More tests => 1; | ||
|
||
use MarpaX::Languages::Bash::AST; | ||
my $grammar = MarpaX::Languages::Bash::AST->new(); | ||
|
||
my $value_ref; | ||
|
||
# This script prints "Hello World.\n" | ||
$value_ref = $grammar->parse( \(<<'EOI') ); | ||
echo ${a:+ | ||
Hello | ||
World.} | ||
EOI | ||
|
||
# Returns some magic foo I don't even know how to describe it. | ||
is_deeply $value_ref, \[ undef ]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use Test::More tests => 2; | ||
|
||
use MarpaX::Languages::Bash::AST; | ||
my $grammar = MarpaX::Languages::Bash::AST->new(); | ||
|
||
my $value_ref; | ||
|
||
$value_ref = $grammar->parse( \(<<'EOI') ); | ||
if :; than :; fi | ||
EOI | ||
|
||
is_deeply $value_ref, \[ [ 'if', [ 'command', ':' ], [ 'command', ':' ], undef ]; | ||
|
||
$value_ref = $grammar->parse( \(<<'EOI') ); | ||
if :; than :; else :; fi | ||
EOI | ||
|
||
is_deeply $value_ref, \[ [ 'if', [ 'command', ':' ], [ 'command', ':' ], [ 'command', ':' ] ]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use Test::More tests => 2; | ||
|
||
use MarpaX::Languages::Bash::AST; | ||
my $grammar = MarpaX::Languages::Bash::AST->new(); | ||
|
||
my $value_ref; | ||
|
||
$value_ref = $grammar->parse( \(<<'EOI') ); | ||
#!/usr/bin/env bc | ||
42 * 1 + 7 | ||
EOI | ||
|
||
is_deeply $value_ref, \[ ['shabang', '/usr/bin/env bc'], 42 * 1 + 7 ]; | ||
|
||
$value_ref = $grammar->parse( \(<<'EOI') ); | ||
#!/usr/bin/env bc | ||
42 * 1 + 7 | ||
42 * 1 + 7 | ||
EOI | ||
|
||
is_deeply $value_ref, \[ ['shabang', '/usr/bin/env bc'], 42 * 1 + 7, 42 * 1 + 7 ]; |