Commit Graph

26 Commits

Author SHA1 Message Date
Andrew Helwer af9646bad9
Fixed CRLF behavior for tests, run tests on all platforms in GitHub CI (#106)
* Fixed CRLF issues in tests

* Added GH CI to ensure tests pass on all platforms
2021-09-25 13:59:45 -07:00
Andrew Hlynskyi 3243c9ab73
fix: escaped newline immediately after a char, resolves #100 (#102) 2021-09-21 21:30:05 -07: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 47f3e5208b Fix brace-nesting logic in regex scanning
Refs #38
2018-11-04 15:34:15 -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 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 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 0e172361a8 Support #*# operator in variable expansions
Fixes #10
2018-08-06 11:09:45 -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 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
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 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 8f67869b16 Use string::copy rather than memcpy 2017-08-01 10:26:42 -07:00
Max Brunsfeld 4340002e38 Implement external scanner serialization 2017-08-01 10:12:16 -07: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 1b5e1557f2 Reorganize, rename a bunch of things 2017-07-15 22:13:55 -07:00
Max Brunsfeld 66693d7575 Add empty environment variable values 2017-07-14 17:41:14 -07:00
Max Brunsfeld a0406c8906 Fix distinction between numeric args and redirect file descriptors 2017-07-14 17:14:23 -07:00
Max Brunsfeld a46748839e Add variable expansion inside of heredocs 2017-07-14 14:27:13 -07:00
Max Brunsfeld 6be8857926 Start work on heredocs 2017-07-14 13:54:05 -07:00