diff --git a/doc/sample/foreach.bshell b/doc/sample/foreach.bshell new file mode 100644 index 0000000..1ccaeaa --- /dev/null +++ b/doc/sample/foreach.bshell @@ -0,0 +1 @@ +Get-Verb | %{ echo "Item: $($_.verb)" } diff --git a/doc/sample/if-else.bshell b/doc/sample/if-else.bshell new file mode 100644 index 0000000..dc6c9e5 --- /dev/null +++ b/doc/sample/if-else.bshell @@ -0,0 +1,7 @@ +if ($x -gt 5) { + echo hi +} elseif ($x -lt 10) { + echo bye +} else { + echo none +} diff --git a/doc/sample/redirection.bshell b/doc/sample/redirection.bshell index 1b09d77..abd54f3 100644 --- a/doc/sample/redirection.bshell +++ b/doc/sample/redirection.bshell @@ -1 +1 @@ -echo hello 2> error.txt | ls -la | echo done; exit -1 +echo hello$name 2> error.txt | ls -la | echo done; exit -1 diff --git a/doc/sample/scriptblock.bshell b/doc/sample/scriptblock.bshell new file mode 100644 index 0000000..433c008 --- /dev/null +++ b/doc/sample/scriptblock.bshell @@ -0,0 +1 @@ +echo 1 2 3 | %{ echo "Item: $_" } diff --git a/doc/sample/simple.bshell b/doc/sample/simple.bshell index 9a101bf..8d4a3a4 100644 --- a/doc/sample/simple.bshell +++ b/doc/sample/simple.bshell @@ -1,5 +1,11 @@ func test-function($name) { - echo "Hello, $name! $(2 + 4 + 2) wow" + if (5 -lt $var) { + echo good + } else { + echo bad + } + + echo "Hello, $name! $(2 + 4 + 2) wow" } # Example of instantiating an FX runtime object. @@ -11,4 +17,6 @@ $hash = @{ 'three' = 3 } +$hash2 = @{ 1 = 'one'; 2 = 'two'; 'three' = 3 } + test-function -name $obj diff --git a/doc/sample/syntax.bshell b/doc/sample/syntax.bshell index 5558338..e9e31d4 100644 --- a/doc/sample/syntax.bshell +++ b/doc/sample/syntax.bshell @@ -31,12 +31,12 @@ $a$b # VAR(a) # VAR(b) -# When the parser encounters SYMBOL(%) it should switch the lexer to COMMAND +# When the parser encounters SYMBOL(&) it should switch the lexer to COMMAND # mode, which will allow the following word construction to be used. # this executes the command whose name is equal to concatenating the values # of $a and $b (in this case, '24') -% $a$b -# SYMBOL(%) +& $a$b +# SYMBOL(&) # WORD_START # VAR(a) # VAR(b) @@ -51,7 +51,7 @@ a+2b # the first char encountered is a symbol, which is read as a word in COMMAND # mode -no$a -# WORD(-no) +# WORD(-no$a) # returns the result of applying the NOT operator to the value of $a. # the first char encountered is a symbol, which is read as a word in COMMAND @@ -62,16 +62,19 @@ a+2b # OP(not) # VAR(a) -# executes the command with the name '-not$a' ($a is NOT substituted) +# executes the command with the name '-not$a' ($a is substituted) # because of the preceding hyphen, variable substitution is not performed. -% -not$a -# SYMBOL(%) -# WORD(-not$a) +& -not$a +# SYMBOL(&) +# WORD_START +# WORD(-not) +# VAR(a) +# WORD_END -# executes the command with the name '-not2' ($a IS substituted) +# executes the command with the name "-not$a" ($a IS substituted) # variable substitution IS performed in dquote strings regardless of the hyphen. -% "-not$a" -# SYMBOL(%) +& "-not$a" +# SYMBOL(&) # STR_START # STRING(-not) # VAR(a)