Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c++ Subject: Re: little contest Date: Fri, 10 Jan 2020 07:44:43 -0800 Organization: A noiseless patient Spider Lines: 56 Message-ID: <864kx35n9w.fsf@linuxsc.com> References: <6wKPF.655039$o8x.81443@fx15.am4> <1f5c9e59-c6d8-4a37-860e-0747d57853ab@googlegroups.com> <1081ff5a-9b29-4065-ac54-3629dcc046fa@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="7b070c0766e341d0df2bb5814a4c869f"; logging-data="24797"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+jzWLXeQj+/I7l6eYhabHwMQqeRla5Z7E=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:NMbEWF8t870t4R36D3GjKitwr9Y= sha1:xmtcHUDgifPmalywmOt/CWnZVSY= Xref: csiph.com comp.lang.c++:71259 Jorgen Grahn writes: [...] > I always assumed parsing meant reading any kind of data, deciding if > it matches the parser's language, and if it does, offering the > "pieces" in a helpful way to the next step of processing. This description is consistent with my own understanding and also with the various definitions and other online resources I consulted. > E.g. yacc is a parser generator, but in my mind so is scanf(). I wouldn't say scanf() is a parser generator, because it doesn't generate a parser but rather goes ahead and does (some) parsing. Perhaps more significantly, usually scanf() is used to parse not an entire language but only some part of an input, with other calls to scanf() parsing other parts of the input (and hence other parts of the language being accepted). To me scanf() is closer to being a lexer than a parser. However these are minor distinctions; it's fair to say that a scanf() call parses a line (or some other part) of an input. > (And as background: I know for sure I was taught in computer science > that "language" is anything with a syntax and (I suppose) semantics. > It doesn't have to be Turing-complete or anything.) In formal Computer Science, a language is any set of strings over a finite alphabet. In most cases we are concerned only with those languages that can be recognized by a computer program, and so necessarily have a finite (and well-defined) "grammar". I put the word "grammar" in quotes only because computer programs are more varied than what is generally meant by the word grammar. By themselves languages are just sets of strings, and do not have any associated semantics. However it is certainly right that a language needn't be large or "complete" in any sense. The set of strings { "cat", "dog" } qualifies as a language in formal language theory. > [...] I tend to do things which fit in Unix pipelines. (Comment about English language usage only.) In English, this sentence is better written using "that" in place of "which". The reason is the word "that" is restrictive, whereas the word "which" is non-restrictive. That should be enough so you can read a more full description somewheres on the web. (Or if not ask and I will try to track down a good reference.) (Note: my comment is meant only to be helpful, not corrective. My friends for whom English is not their first language tell me it's helpful for them to hear remarks like this, so their English can be better. That's all I'm trying to do here.)