-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
no support for herestrings (<<<) #49
Comments
Thanks for the example and the equivalence, this will help to do a test case :-) |
Thank you, this is already known, there should be an issue or doc that mentions the lack of herestring. It should be the last POSIX statement missing... Would you mind doing a PR to implement it? I could provide some suggestion on the sources you have to change to implement it. |
if you can point me in the right direction for getting it fixed, I'll give it a shot. thanks! I poked around but didn't see this issue documented anywhere. it took me a while to figure out what |
Awesome!
Ah sorry, I was speaking about POSIX heredocs (that are also missing); I misunderstood you... The operator you're talking about is the last one in the list... The error you are seeing is because the tokenizer is not aware of the <<< operator, and it is interpreting them (I guess) as tree < (LESS) operators in sequence. and that is not a valid syntax... |
First, you'll have to change how the bash mode is inherited from POSIX mode. You can start look here: That module export an object that define the bash mode.
and an init function, that the system will call passing the base POSIX mode and an utils object as argument. |
The POSIX object you receive in {
enums, // various enums used by the mode
tokenizer, // the tokenizer: String -> Iterable<Object>
lexerPhases // The lexer "enhance" the tokens in a way that they can be understood by the grammar. Is implemented as a list of iterators, composed together. Each of these iterators are keep in the phaseCatalog
phaseCatalog,
grammarSource, // the grammar source code
grammar, // the grammar built using jison
astBuilder // build the AST nodes for each of the grammar production
}; You probably could implement the <<< operator by adding a phase to the lexer that check for threee consecutive 'LESS' tokens, and, if the pattern is found, it emit a 'CALL-IT-SOMEHOW' tokens. Then, you'll have to extend the grammar to take into account the new token. remember that the grammar has to be recompiled using https://github.com/vorpaljs/mode-grammar-builder |
I suggest you to open a PR early, we can continue the discussion there if you have any doubt... |
hey, sorry for the late reply. Things have gotten hectic and I don't think I'm going to have time to put together a pull-request. I don't wanna leave you guys hanging. |
The herestring (
<<<
) operator in bash is used to pass literal strings/variables into the STDIN of another command. For example. the following two lines are functionally equivalent:Trying to parse this with bash-parser results in a parse error:
documentation on the herestrings: http://tldp.org/LDP/abs/html/x17837.html
The text was updated successfully, but these errors were encountered: