Re: [sicsh-develop] Re: Syntax hooks
Status: Alpha
Brought to you by:
gvv
From: Gary V. V. <ga...@or...> - 2000-04-13 23:12:35
|
On Thu, Apr 13, 2000 at 04:25:21PM -0400, Ezra Peisach wrote: > > > Sorry for not getting back sooner: No worries... I'm busy too (as you know) =)O| > >I wonder whether we also need to provide hooks at various points in > >the code between building the input buffer and passing parts of the > >Tokens* array into the evaluator... > This would would what? > >A cleaner way to implement `$' substitution would be let the dollar > >module register a hook function after tokenisation that rewrites any > >token that begins with a `$'. The module would still need to provide > >a syntax handler to keep all of $(foo bar baz) in a single token (or > >maybe just a flag like we do for strings?). > > This could also work with equals, etc. This makes the syntax tables > responsible for the breaking the line into tokens. The Syntax_Hook can > then handle the context specific requirements and rewriting. Cool. I'll consider that as an endorsement. Feel free to implement it if you want, otherwise I'll get to it in the first few weeks of May. > >The only sane way I can think of to implement globbing is to register > >a hook function that rewrites the buffer contents with any glob > >expansions done. In this case the function would need to be called > >before the syntax pass in tokenize(). > > I do not follow this reasoning. What exactly are you trying to expand > with glob expansion? Filenames? Commands? Filenames could be handled > at the Syntax_Hook level. Please elaborate. The current mechanism simply can't express code to implement bourne shell file globbing: $ ls *.[ch] With an syntax hook function, words which contain unquoted globbing meta-characters could be rewritten into the buffer as their expansion (unless there are no matches, when the original string is kept -- meta-chars and all). > Therefore, I like the Syntax_Hook, but am not convinced of the need > for the init_hooks. I think the globbing needs to happen before word splitting, otherwise the glob expansion will be a single token (like $ expansion). If it is expanded before the word splitting phase, each expanded file would be correctly alloted to a single token (think: `for file in *'). The alternative is pass the expanded glob expression back through tokenize, and squash the returned words into the array from before the glob expansion. Yuck. init_hooks allow for much nicer code. Cheers, Gary. -- ___ _ ___ __ _ mailto:ga...@or... / __|__ _ _ ___ _| | / / | / /_ _ _ _ __ _| |_ __ _ ___ ga...@gn... | (_ / _` | '_|// / |/ /| |/ / _` | || / _` | ' \/ _` | _ \ \___\__,_|_|\_, /|___(_)___/\__,_|\_,_\__, |_||_\__,_|//_/ home page: /___/ /___/ gpg public key: http://www.oranda.demon.co.uk http://www.oranda.demon.co.uk/key.asc |