Re: Is it always possible to make a non-reentrant parser reentrant?

2019-02-12 Thread Hans Åberg
> On 12 Feb 2019, at 20:27, Peng Yu wrote: > >> We should probably offer an example of a pull parser in examples/c. >> Have a look at the documentation to have an idea of what I mean. > > OK. I will take a look at it. > > Bash uses one parser to deal with both interactive run and > non-intera

Re: Is it always possible to make a non-reentrant parser reentrant?

2019-02-12 Thread Peng Yu
> We should probably offer an example of a pull parser in examples/c. > Have a look at the documentation to have an idea of what I mean. OK. I will take a look at it. Bash uses one parser to deal with both interactive run and non-interactive run and uses a global variable to test whether the run

Re: When to use a token yacc_EOF instead of relying on 0 return value of yylex()?

2019-02-12 Thread Akim Demaille
> Le 11 févr. 2019 à 23:56, Peng Yu a écrit : > >> I have no idea. You'd have to study the grammar to see if there >> are doing fancy things around yacc_EOF. > > declare -p BASH_SOURCE > > Here is what I got with the above one line bash code (with the newline > at the end). > > The lines wi

Re: Is it always possible to make a non-reentrant parser reentrant?

2019-02-12 Thread Akim Demaille
> Le 12 févr. 2019 à 17:38, Akim Demaille a écrit : > >> I’d like to know what is the best way to structure the parsing code. Given >> a lot of code of bash started 30 years ago, I’d expect at least some part >> of the code is not the best according to today’s standard. I’d like to >> know any

Re: Is it always possible to make a non-reentrant parser reentrant?

2019-02-12 Thread Akim Demaille
> Le 9 févr. 2019 à 00:21, Peng Yu a écrit : > > Hi Simon, > >> Normally, you'd use lexer states to activate/deactivate rules. The >> primitive approach would be >> >> %x INITIAL HEREDOC > > I see %x is from flex. Bash can support nested heredoc. How can it be > implemented in flex? Flex of

Re: Is it always possible to make a non-reentrant parser reentrant?

2019-02-12 Thread Akim Demaille
hi! > Le 8 févr. 2019 à 12:39, Peng Yu a écrit : > > On Thu, Feb 7, 2019 at 11:49 PM Akim Demaille wrote: > >> I'm a bit confused here: did you really mean "another parser", or did >> you mean "another scanner"? If you do mean "another parser", I'm not >> sure how you would coordinate the sev

Re: Is it always possible to make a non-reentrant parser reentrant?

2019-02-12 Thread Hans Åberg
> On 9 Feb 2019, at 00:21, Peng Yu wrote: > >> %x INITIAL HEREDOC > > I see %x is from flex. Bash can support nested heredoc. How can it be > implemented in flex? For nested environments one uses a stack, if there are local variables to keep track of. Such switches will then appropriately ha