parser/arithm: fix && and ||
"&" and "|" have higher priority, so they were consuming the first character of
"&&" and "||", leaving a trailing "&" or "|".
parser/arithm: fix comparison operators
> and < were recognized before >= and <=. For this reason, >= and <= were never
parsed (since they are prefixes of < and >).
ast: add mrsh_node
This adds mrsh_node_type to all AST nodes. This makes it possible to implement
operations over the whole tree much more easily.
Rename node to and_or_list
This is the term used by the spec.
parser: fail on invalid parameter
POSIX says '$' followed by an invalid character is unspecified behaviour. Make
the parser fail instead of handling it as a string.
This diverges from the dash implementation.
Fixes: aff5a58f0f99 ("parser: handle `$` followed by invalid char more gracefully")
parser: handle `$` followed by invalid char more gracefully
e.g. `$ ` and `$\n`
POSIX says it's undefined behaviour.
Accept spaces inside arithmetic expressions
Fix parser choking on certain arithmetic operators
Specifically '&', '|', '/', '<', and '>' in arithmetic expressions.
Rename *_func_t types to *_func
POSIX reserves the _t suffix, so it's advisable to avoid it.
Parse arithmetic expressions with shifts
We introduce the function arithmetic_word() to parse arithmetic
expressions instead of reusing the general word(), and generalize
word_list() to receive a pointer to function, so that word_list() may be
used to parse a list of whatever type of word we need.
This fixes #51, and enables properly parsing parenthesized expressions
inside arithmetic expressions, e.g. $(((2+1)-1)).
https://github.com/emersion/mrsh/issues/73 part 2
parser: fix io_number
Fix continuation lines in interactive mode
parser: add mrsh_parser_from_buffer
This allows the user to share a buffer with the parser. This is especially
useful when managing manually how input lines are read (e.g. for interactive
shells). Before each mrsh_parse_line call, the user can fill the shared buffer
with the (maybe incomplete) input.
Move away from FILE
parser: finish arithmetic expression parser
parser: add a few binary arithmetic operations
parser: parse arithmetic unop and parens