zsh-users
 help / color / mirror / code / Atom feed
From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: triviality with prompts
Date: Sat, 06 Dec 2014 16:37:21 -0800	[thread overview]
Message-ID: <5483A141.4090306@eastlink.ca> (raw)
In-Reply-To: <141206132828.ZM2258@torch.brasslantern.com>

On 12/06/2014 01:28 PM, Bart Schaefer wrote:
> Not exactly.  It's a delineated block of characters in which a defined
> syntax will apply.  Of course in the colloquial sense the meaning of an
> individual grapheme in a syntax is its "semantics", but in the computer
> science sense the syntax and semantics of a language are distinct.
Yeah, may as well be strict.  I don't want to split hairs too finely tho,
and I only know the rules for this in natural language.
> Quoting defines the meaning of individual characters, e.g., transforming
> the digraph \n into something else -- either a literal "n" or a newline,
> depending on the interpretation of the backslash.  Quoting also creates
> a syntactic unit, affecting how a collection of graphemes is assembled
> into tokens (most often, resulting in a single token instead of many,
> and usually resulting in tokens that are treated as plain strings and
> not as having any particular higher-level meaning).
>
> Constructs like $( ) define the meaning and higher-level structure of
> the language tokens that came from interpretation of the syntax.  The
> shell language is unusual among programming languages in that it allows
> certain semantic constructs to be interpreted even when inside certain
> syntactic constructs (double-quoting, mostly), so that it's necessary
> to interleave syntactic and semantic analysis (and even execution of
> the code resulting from the latter) to arrive at a final tokenization.
>
> Most programming languages force you to make that explicit, but the
> shell is all about building up or cutting up strings by implicit con-
> catenation and delineation, so it takes all kinds of shortcuts that
> make the language ugly to formally define but faster to interact with
> in the common cases.
You know, once you 'just say it' half the problem goes away.  I'm still
looking for rigor.  Once I just stop looking for it I won't get into a 
lather
nearly so  often.

> E.g. in
> 	'$(echo foo bar)'
> the definition of single quotes means that none of $ ( or ) is special,
> and results in one plain-string token made up of the characters between
> the single quotes.  Conversely in
> 	"$(echo foo bar)"
> the definition of double quotes means that $ is special, which in turn
> means that the digraph $( introduces a subexpression that has to be
> interpreted using the higher-level rules of command substitution, which
> consumes everything up through the closing paren.  The final token can
> only be generated after the command inside the parens is executed and
> its output captured, but it still results in only one plain string.
>
> Compare to $(echo foo bar) without the quotes, which normally results
> in two string tokens foo and bar, or to
> 	"\$(echo foo bar)"
> where the definition of backslash means that the digraph \$ transforms
> into a non-special $ which therefore is NOT part of a $( digraph and
> therefore does not introduce command substitution.
>
> } Maybe what I'm reaching for with the list above is a complete list of
> } 'delineators'.  So, if one had such a list, one could learn the syntactic
> } rules inside each one in a tractable way.
>
> In zsh's info doc, sections 6.9 (Quoting) and 14 (Expansion) together
> make up that list.
>
That, sir, was beautifully written.


  reply	other threads:[~2014-12-07  0:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-03  0:17 Ray Andrews
2014-12-03  3:02 ` Bart Schaefer
2014-12-03  4:28   ` Ray Andrews
2014-12-03  4:38     ` Lawrence Velázquez
2014-12-03 16:20       ` Ray Andrews
2014-12-03 16:43         ` Roman Neuhauser
2014-12-03 17:10           ` Ray Andrews
2014-12-03 17:39             ` Roman Neuhauser
2014-12-03 21:14             ` Bart Schaefer
2014-12-03 23:14               ` Ray Andrews
2014-12-04  5:06                 ` Bart Schaefer
2014-12-04 18:42                   ` Ray Andrews
2014-12-06 21:28                     ` Bart Schaefer
2014-12-07  0:37                       ` Ray Andrews [this message]
2014-12-03 21:16         ` Lawrence Velázquez
2014-12-03 21:22         ` Bart Schaefer
2014-12-03 23:40           ` Ray Andrews

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5483A141.4090306@eastlink.ca \
    --to=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).