Groups | Search | Server Info | Login | Register
Groups > comp.lang.c.moderated > #481
| From | Francis Glassborow <francis.glassborow@btinternet.com> |
|---|---|
| Newsgroups | comp.lang.c.moderated |
| Subject | Re: Convert string to C expression syntax |
| Date | 2013-09-12 11:38 -0500 |
| Organization | Usenet Fact Police |
| Message-ID | <clcm-20130912-0005@plethora.net> (permalink) |
| References | <clcm-20130730-0006@plethora.net> <clcm-20130906-0005@plethora.net> <clcm-20130911-0003@plethora.net> |
On 11/09/2013 23:27, James Kuyper wrote:
> On 09/07/2013 12:25 AM, Paul D. DeRocco wrote:
>> > On 7/30/2013 7:58 PM, nilay wrote:
>> >
>>> I want to do the following,
>>>
>>> ==========================================
>>> int main(int argc, char *argv[])
>>> {
>>>
>>> ...
>>> ...
>>> if (*argv[1])
>>> {
>>> ...
>>> }
>>>
>>> ...
>>> }
>>> ==========================================
>>>
>>> as i tried to show above, I want to pass a filter condition
>>> at command-line input. And I want to convert that input string
>>> to 'if-condition expression' so that it can be used in the program.
>>> How can it be done?? I am struggling very hard to get it right.
>>
>> You can't do this in C. If you want to do stuff like this, you should
>> take up Python instead.
>
> You can't do this that way in C, nor in any other simple way. It might
> be simpler to do it in Python, but it certainly can be done in C. You
> just need to write code for parsing the condition expression, and then
> evaluating it. If the condition expression has a very simple syntax,
> that's trivial to do. However, even if he wants to support the full
> complexity of a C-like syntax, it should still be feasible. Components
> (or at least, design ideas) borrowed from a C compiler should be
> adaptable to this use. C has famously been a bootstrapped language: more
> advanced versions of C were first implemented by using more primitive
> versions of C to write the compiler, so such components can certain be
> written in C.
Yes and if you are running C on an interpreter (they do exist) it comes
about pretty naturally.
Francis
>
--
comp.lang.c.moderated - moderation address: clcm@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
Back to comp.lang.c.moderated | Previous | Next — Previous in thread | Next in thread | Find similar
Convert string to C expression syntax nilay <nilaybhatt@gmail.com> - 2013-07-30 21:58 -0500
Re: Convert string to C expression syntax James Kuyper <jameskuyper@verizon.net> - 2013-07-31 21:22 -0500
Re: Convert string to C expression syntax Barry Schwarz <schwarzb@dqel.com> - 2013-07-31 21:22 -0500
Re: Convert string to C expression syntax Keith Thompson <kst-u@mib.org> - 2013-08-01 12:58 -0500
Re: Convert string to C expression syntax Ike Naar <ike@ukato.freeshell.org> - 2013-08-01 21:05 -0500
Re: Convert string to C expression syntax Keith Thompson <kst-u@mib.org> - 2013-08-02 18:34 -0500
Re: Convert string to C expression syntax gordonb.uvkjx@burditt.org (Gordon Burditt) - 2013-07-31 21:22 -0500
Re: Convert string to C expression syntax Roberto Waltman <usenet@rwaltman.com> - 2013-08-05 11:24 -0500
Re: Convert string to C expression syntax malcolm.mclean5@btinternet.com - 2013-09-02 04:09 -0500
Re: Convert string to C expression syntax "Paul D. DeRocco" <pderocco@ix.netcom.com> - 2013-09-06 23:25 -0500
Re: Convert string to C expression syntax James Kuyper <jameskuyper@verizon.net> - 2013-09-11 17:27 -0500
Re: Convert string to C expression syntax "Paul D. DeRocco" <pderocco@ix.netcom.com> - 2013-09-12 11:34 -0500
Re: Convert string to C expression syntax Francis Glassborow <francis.glassborow@btinternet.com> - 2013-09-12 11:38 -0500
Re: Convert string to C expression syntax Nitin Tripathi <2nitintr@gmail.com> - 2013-09-11 17:31 -0500
csiph-web