Commit Graph

80 Commits

Author SHA1 Message Date
Ryan Despain 275effdfc0
adding zsh expansion flagsSee https://zsh.sourceforge.io/Doc/Release/Expansion.html\#Parameter-Expansion-Flags (#115) 2021-12-15 08:53:04 -08:00
oxalica 4094e3a040
Handle words containing bare '#' (#109)
* Handle words containing bare '#'

Only a word beginning with a '#' starts a comment. A word can contain
'#' character without escaping as long as it is not the first character.

See: Bash Reference Manual section '3.1.3 Comments'
https://www.gnu.org/software/bash/manual/bash.html#Comments

* Regenerate
2021-11-01 09:59:27 -07:00
Martin Jambon 9d9325f8f9 Add support for 'until' loops 2021-10-16 01:44:38 -07:00
Martin Jambon c79d2377d4 Add support for 'select' loops. 2021-10-09 02:44:05 -07:00
Andrew Hlynskyi 3243c9ab73
fix: escaped newline immediately after a char, resolves #100 (#102) 2021-09-21 21:30:05 -07:00
Kenneth Skovhus 8ece09ca4c
Add support for case fallthrough (#85)
Fixes https://github.com/tree-sitter/tree-sitter-bash/issues/40
2020-05-29 13:09:38 -07:00
Kenneth Skovhus f226a4b55a
Add support for empty expansions (#82)
Fixes https://github.com/tree-sitter/tree-sitter-bash/issues/57
2020-05-15 12:32:47 -07:00
Kenneth Skovhus 38e8ba4a3d
Expand function definition to support subshell and tests (#83)
Fixes https://github.com/tree-sitter/tree-sitter-bash/issues/60
2020-05-15 11:25:46 -07:00
Kenneth Skovhus 0477cc4460
Add support for ternary expression (#81)
Fixes https://github.com/tree-sitter/tree-sitter-bash/issues/64
2020-05-15 10:50:29 -07:00
Šimon Let 28e76c616d
WIP: Add '>|' redirection to grammar (#75)
* Add '>|' redirection to grammar

* add tests for >|

* generate grammar
2020-05-14 15:48:18 -07:00
Max Brunsfeld de690d849a Start adding fields 2019-12-10 13:18:29 -08:00
Nathan Sobo 1c48cd1676 Support ANSII-C quoting in strings prefixed with $
See 
https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html 
for details
2019-07-26 11:29:35 -06:00
Max Brunsfeld 3b15f16973 Fix CRLF handling in external scanner 2019-07-03 12:01:02 -07:00
Jason Rudolph 4f3cbc36b9 Handle heredoc delimiters that include spaces (#47)
* Handle heredoc delimiters that include spaces

* Update test to use multi-line heredoc to demonstrate bug

This change demonstrates the bug described in 
https://github.com/tree-sitter/tree-sitter-bash/pull/47#discussion_r280183823.

* Handle multi-line heredocs with spaces in delimiter

Fixes the failing test introduced in 0d8adbc335.

/xref https://github.com/tree-sitter/tree-sitter-bash/pull/47#discussion_r280183823
2019-05-01 13:59:21 -07:00
Max Brunsfeld 15a3a168f0 Handle
Fixes #39
2019-04-18 15:46:58 -07:00
Max Brunsfeld e9748c132b Require a terminator at the ends of some compound statements
Fixes #44
2019-04-18 15:38:39 -07:00
Max Brunsfeld 53446e0e81 Handle heredocs followed by pipes or redirects
Fixes atom/language-shellscript#134
2019-04-18 15:25:40 -07:00
Max Brunsfeld 25f56dd856 Allow $ at the end of a bare word
Fixes #38
2018-11-04 15:34:33 -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 4fb4e2960d Fix handling of escaped chars in strings 2018-10-18 15:28:46 -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 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 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 2d96fc5fcb Add more code to the case statements test 2018-03-16 15:41:09 -07: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 0791027596 Add regex syntax inside of expansions 2018-03-01 10:41:16 -08:00
Max Brunsfeld f33bf06de2 Distinguish unset commands from regular commands 2018-03-01 10:12:10 -08:00
Max Brunsfeld 69d64558a3 Rename control_flow test file to statements 2018-03-01 10:06:38 -08:00
Max Brunsfeld 384d920af5 Allow $ in strings 2018-03-01 09:54:08 -08:00
Max Brunsfeld c7e42b8e96 Add special lexing for regexes after `=~` 2018-03-01 09:53:10 -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 2a5b01b885 Generalize parsing of expansion operators 2018-02-28 16:28:55 -08:00
Max Brunsfeld 86c5561ba8 Allow file redirects on while statements 2018-02-28 16:28:30 -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