Commit Graph

10 Commits

Author SHA1 Message Date
Max Brunsfeld 675a581839 Allow special characters in bare word arguments
I've moved tokenization of bare words into the external scanner. This
way we can keep the grammar simple, but support some fancy rules that
I've inferred from experimenting with bash:

- Only allow '}' inside of a bare word if '}' isn't a valid lookahead
token (i.e. we're not inside of a variable expansion).
- Only allow ']' at the *start* of a bare word if neither ']' nor ']]'
are valid lookahead tokens (i.e. we're not inside of a square bracket
command or an array subscript).
- Parentheses seem to never be allowed in bare words. You have to quote
them.

For alphanumeric words, I fall through to the normal scanner so that it
can continue to distinguish reserved words from other words.

Fixes #5
2018-02-27 16:55:20 -08:00
Mads Hartmann 8ca2ecd52d Add support for exporting environment variables (#4)
* Add support for exporting environment variables

* Support multiple exports in one command

Also improves the structure of the AST so the variable name and the
assigned expression aren't free-floating

* Allow for multiple declarations in local declarations as well

Simplify the generated nodes.

* Commit generated code

* Consolidate declarations into a single declaration_command

This also adds support for declare, typeset, and readonly

* Rename environment_variable_assignment to variable_assignment
2018-02-27 13:22:28 -08:00
Mads Hartmann 0ed39445d3 Support local variable declarations 2018-02-25 00:02:24 +01:00
Mads Hartmann 741cfce4b4 Handle empty default value during variable expansion (#1)
* Handle empty default value during variable expansion

* Make expression after colon optional

As suggested by @maxbrunsfeld
2018-02-24 13:40:43 -08:00
Max Brunsfeld 145d4e86a4 Add missing array syntax 2017-12-26 14:55:37 -08:00
Max Brunsfeld dce4ee6937 Handle words concatenated with strings and expansions 2017-07-17 10:47:34 -07:00
Max Brunsfeld 403361626d Add length operator in variable expansions 2017-07-15 23:12:22 -07:00
Max Brunsfeld 3abfbbd7bd Handle strings containing command substitutions 2017-07-15 22:41:56 -07:00
Max Brunsfeld 5081293f65 Add process substitutions 2017-07-15 22:22:38 -07:00
Max Brunsfeld 1b5e1557f2 Reorganize, rename a bunch of things 2017-07-15 22:13:55 -07:00