Commit Graph

73 Commits

Author SHA1 Message Date
Max Brunsfeld 25f56dd856 Allow $ at the end of a bare word
Fixes #38
2018-11-04 15:34:33 -08:00
Max Brunsfeld 47f3e5208b Fix brace-nesting logic in regex scanning
Refs #38
2018-11-04 15:34:15 -08:00
Max Brunsfeld 8426c3fefd Fix handling of delimiter characters as part of bare words
Fixes atom/atom#18387
2018-11-04 13:14:13 -08:00
Max Brunsfeld da116a1941 Handle heredocs w/ indented close delimiters
Fixes atom/language-shellscript#127
2018-10-19 13:06:56 -07:00
Max Brunsfeld a4fb636b2d Handle shorthand file redirect command substitutions
Fixes #34
2018-10-18 15:31:24 -07:00
Max Brunsfeld 48f7e22475 Handle lists of statements more consistently 2018-10-18 15:29:07 -07:00
Max Brunsfeld bdaf31057b Add raw (quoted) heredocs
Fixes #31
2018-10-18 12:55:14 -07:00
Max Brunsfeld 46cf157ad8 Handle escaped expansions in heredocs
Fixes #28
2018-10-18 11:12:48 -07:00
Max Brunsfeld cdbc8863cd Allow compound statements and redirects in more places
Fixes #35
2018-10-18 11:06:03 -07:00
Max Brunsfeld 246bad66dd Add double-paren expression
* Use the external scanner for regexes
* Add some missing operators

Fixes #22
Fixes #32
2018-10-01 13:29:04 -07:00
Max Brunsfeld 0123b9559f Allow semicolon before block in c-style for loop
Fixes #33
2018-10-01 12:48:50 -07:00
Max Brunsfeld 6ff7fe3c7e Don't require statement terminator at EOF
Fixes #15
2018-08-06 11:18:33 -07:00
Max Brunsfeld da2ba9cfdf Allow backslashes between tokens
Fixes #14
2018-08-06 11:14:00 -07:00
Max Brunsfeld 0e172361a8 Support #*# operator in variable expansions
Fixes #10
2018-08-06 11:09:45 -07:00
Max Brunsfeld 3a9b32284e Allow `!` operator in variable expansions
Fixes #21
2018-08-06 10:44:13 -07:00
Kenneth Skovhus 08cf72b615 [WIP] Support multiple statements (#26)
* Rename prebuild target clashing with build target

* Add test:watch target and documentation

* Support multiple statements in substitutions

* Inline the _statements rule

This removes a reduction step by the `_statements -> _statement` rule,
which avoids a reduce/reduce conflict between `_statements` and
`command`.
2018-08-06 10:39:05 -07:00
Kenneth Skovhus 9bbd80dee1 Add support for C-style for statements (#23) 2018-08-05 19:25:19 -07:00
Kenneth Skovhus 886a957d1e Add support for strings ending with $ (#24) 2018-08-02 16:32:30 -07:00
Max Brunsfeld 7873b864b1 ⬆️ tree-sitter-cli (new ABI version) 2018-07-18 13:19:42 -07:00
Max Brunsfeld 44b3de2594 ⬆️ tree-sitter-cli, add explicit word token 2018-06-15 14:05:05 -07:00
Max Brunsfeld 7b003599b3 Allow subshells in negated commands
Fixes #13
2018-05-24 15:00:53 -07:00
Max Brunsfeld 065a4ec425 Rework test expressions
Fixes #11
2018-05-24 11:47:12 -07:00
Max Brunsfeld 73d6705bc2 Allow other redirects between a heredoc's delimiter and body
Fixes #16
2018-03-29 09:54:08 -07:00
Max Brunsfeld f478eaddb3 ⬆️ tree-sitter-cli 2018-03-28 11:18:32 -07:00
Max Brunsfeld 90552dc38b ⬆️ tree-sitter 2018-03-05 17:44:34 -08:00
Max Brunsfeld 68e93bd898 Allow for statements without in clauses 2018-03-02 10:18:42 -08:00
Max Brunsfeld 87a832d94e Allow regexes after '==', not just '=~' 2018-03-01 14:22:38 -08:00
Max Brunsfeld c7484ad85f Allow ;; at end of line of case item 2018-03-01 14:04:29 -08:00
Max Brunsfeld 51b212b207 Allow redirects after bracket commands 2018-03-01 10:42:20 -08:00
Max Brunsfeld f33bf06de2 Distinguish unset commands from regular commands 2018-03-01 10:12:10 -08:00
Max Brunsfeld 384d920af5 Allow $ in strings 2018-03-01 09:54:08 -08:00
Max Brunsfeld 0d9f854862 Revert "Don't parse square bracket commands as special syntax"
This reverts commit c34619a1c4.

Bracket command syntax was actually not interfering with the parsing
of words with special characters.
2018-02-28 22:46:47 -08:00
Max Brunsfeld 4920373ca4 Add special variable @, expressions in declarations 2018-02-28 17:32:48 -08:00
Max Brunsfeld 87b3276186 Generalize case statement parsing
* Fix handling of '|' in case items
* Don't require ;; for last case item

Fixes #8
2018-02-28 16:29:42 -08:00
Max Brunsfeld 6f81608535 Always lex braces and brackets as separate tokens
The lexer needs to always return braces and brackets separately so that
the parser can decide if they are part of some construct like an array
subscript or a variable expansion. This means that there was no point
in moving bare-word tokenization into the external scanner. I've moved
it back into the normal scanner.

The tricky part is how to deal with the separate '}' and ']' tokens
in the case where they are *not* part of a subscript or an expansion.
For example, in code like `echo {hi}`, the syntax tree should still
clearly indicate that only *one* argument is being passed to echo.
For now, we achieve this by grouping the '{', hi, and '}' tokens into
a single `concatenation` node, which is a bit odd, but it's the best
we can do.
2018-02-28 14:33:50 -08:00
Max Brunsfeld c34619a1c4 Don't parse square bracket commands as special syntax 2018-02-28 14:32:58 -08:00
Mads Hartmann c410548caf Handle escape sequences in strings (#7)
This should fix #6
2018-02-28 12:15:05 -08:00
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
Max Brunsfeld 8a0a4a8501 Parse for loop identifier as a variable name
Also remove some duplication in expression and concatenation
2018-02-27 13:46:36 -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 31c17c066b Regenerate with latest tree-sitter 2018-02-12 16:53:11 -08:00
Max Brunsfeld 0259c5bce2 Guard against buffer overflow when serializing scanner
/cc philipturnbull
2018-01-19 09:52:45 -08:00
Max Brunsfeld 145d4e86a4 Add missing array syntax 2017-12-26 14:55:37 -08:00
Max Brunsfeld 52d54bb173 Add missing function definition forms 2017-12-26 14:27:05 -08:00
Max Brunsfeld d85b6287e6 Upgrade tree-sitter for new lexer API 2017-12-21 17:13:14 -08:00
Max Brunsfeld e51dfb661a Regenerate with latest tree-sitter 2017-09-18 09:32:01 -07:00
Max Brunsfeld 8f67869b16 Use string::copy rather than memcpy 2017-08-01 10:26:42 -07:00
Max Brunsfeld ccc07eab4b Use new alias API 2017-08-01 10:17:28 -07:00