Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #1630 > unrolled thread
| Started by | Rui Maciel <rui.maciel@gmail.com> |
|---|---|
| First post | 2012-05-27 17:29 +0100 |
| Last post | 2012-05-29 07:50 +1200 |
| Articles | 11 — 7 participants |
Back to article view | Back to comp.programming
Suggestions for a preprocessor Rui Maciel <rui.maciel@gmail.com> - 2012-05-27 17:29 +0100
Re: Suggestions for a preprocessor Fritz Wuehler <fritz@spamexpire-201205.rodent.frell.theremailer.net> - 2012-05-28 02:16 +0200
Re: Suggestions for a preprocessor Rui Maciel <rui.maciel@gmail.com> - 2012-05-28 12:32 +0100
Re: Suggestions for a preprocessor "BartC" <bc@freeuk.com> - 2012-05-28 13:51 +0100
Re: Suggestions for a preprocessor Rui Maciel <rui.maciel@gmail.com> - 2012-05-28 16:19 +0100
Re: Suggestions for a preprocessor Rui Maciel <rui.maciel@gmail.com> - 2012-05-28 16:43 +0100
Re: Suggestions for a preprocessor "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2012-05-28 14:45 +0100
Re: Suggestions for a preprocessor Rui Maciel <rui.maciel@gmail.com> - 2012-05-28 16:21 +0100
Re: Suggestions for a preprocessor Patricia Shanahan <pats@acm.org> - 2012-05-28 16:33 -0700
Re: Suggestions for a preprocessor Nomen Nescio <nobody@dizum.com> - 2012-05-28 16:46 +0200
Re: Suggestions for a preprocessor Ian Collins <ian-news@hotmail.com> - 2012-05-29 07:50 +1200
| From | Rui Maciel <rui.maciel@gmail.com> |
|---|---|
| Date | 2012-05-27 17:29 +0100 |
| Subject | Suggestions for a preprocessor |
| Message-ID | <jptkpd$shr$1@speranza.aioe.org> |
If you were given the task of generating a set of text files whose different versions differed only in a set of numerical values, which tool would you choose? The first tool that jumped to my mind was the M4 preprocessor, but it appears it doesn't handle algebraic operations that well. Thanks in advance, Rui Maciel
[toc] | [next] | [standalone]
| From | Fritz Wuehler <fritz@spamexpire-201205.rodent.frell.theremailer.net> |
|---|---|
| Date | 2012-05-28 02:16 +0200 |
| Message-ID | <500cea953a95c9b8c8212d840d9558a9@msgid.frell.theremailer.net> |
| In reply to | #1630 |
Rui Maciel <rui.maciel@gmail.com> wrote: > If you were given the task of generating a set of text files whose different > versions differed only in a set of numerical values, which tool would you > choose? diff? > The first tool that jumped to my mind was the M4 preprocessor, but it > appears it doesn't handle algebraic operations that well. m4 doesn't seem to do anything well except edit sendmail.cnf files
[toc] | [prev] | [next] | [standalone]
| From | Rui Maciel <rui.maciel@gmail.com> |
|---|---|
| Date | 2012-05-28 12:32 +0100 |
| Message-ID | <jpvnnr$e2e$1@speranza.aioe.org> |
| In reply to | #1632 |
Fritz Wuehler wrote: > Rui Maciel <rui.maciel@gmail.com> wrote: > >> If you were given the task of generating a set of text files whose >> different versions differed only in a set of numerical values, which tool >> would you choose? > > diff? The objective is to generate a set of files with present different values specified by a parameter. For example, let's assume we have this template: <example> Line (0,0) (XX,YY) </example> And, based on this template, a user intended to define N different data files, each one with different values for (XX, YY), with the values for XX and YY being defined in terms of an arbitrary algebraic expression. >> The first tool that jumped to my mind was the M4 preprocessor, but it >> appears it doesn't handle algebraic operations that well. > > m4 doesn't seem to do anything well except edit sendmail.cnf files After a bit of digging, I also ended up with the idea that m4 is limited to the point it is essentially useless. Someone correct me if I'm wrong, but it appears m4 only supports algebraic operations on integers. If it doesn't support floating point operations, or even decimal fractions, then it is essentially irrelevant for any task which involves non-integer numberical values. Rui Maciel
[toc] | [prev] | [next] | [standalone]
| From | "BartC" <bc@freeuk.com> |
|---|---|
| Date | 2012-05-28 13:51 +0100 |
| Message-ID | <jpvsbu$qes$1@dont-email.me> |
| In reply to | #1633 |
"Rui Maciel" <rui.maciel@gmail.com> wrote in message news:jpvnnr$e2e$1@speranza.aioe.org... > Fritz Wuehler wrote: > >> Rui Maciel <rui.maciel@gmail.com> wrote: >> >>> If you were given the task of generating a set of text files whose >>> different versions differed only in a set of numerical values, which >>> tool >>> would you choose? >> >> diff? > > The objective is to generate a set of files with present different values > specified by a parameter. For example, let's assume we have this > template: > > <example> > Line (0,0) (XX,YY) > </example> > > And, based on this template, a user intended to define N different data > files, each one with different values for (XX, YY), with the values for XX > and YY being defined in terms of an arbitrary algebraic expression. Why do you need a preprocessor? It seems to me that any simple language will do the job. Or is this example embedded in a mass of other text? Perhaps a more complete example is needed. Even then, if the input is line oriented (so you don't need macro expansions in the middle of a line, and don't need nested macros), a simple language might still work. -- Bartc
[toc] | [prev] | [next] | [standalone]
| From | Rui Maciel <rui.maciel@gmail.com> |
|---|---|
| Date | 2012-05-28 16:19 +0100 |
| Message-ID | <jq051s$jer$1@speranza.aioe.org> |
| In reply to | #1634 |
BartC wrote: > Why do you need a preprocessor? It seems to me that any simple language > will do the job. As the task consisted of, basically, defining a template for a document and, from that, create a series of documents by replacing a given variable with a value, it appeared that the best way to go around doing this would be with a macro processor. > Or is this example embedded in a mass of other text? Yes. Although the example I've provided is a bit slimsy on the details, basically what I intended to do was create a template for a document that defined a model in terms of a set of parameters. Then, that template would be used to create a series of models which reflected the way a given parameter was tweaked. > Perhaps a more > complete example is needed. Even then, if the input is line oriented (so > you don't need macro expansions in the middle of a line, and don't need > nested macros), a simple language might still work. Since I've started this thread, I've started writing a small Perl script to generate the models. Perl's support for here-document string literals appears to do a decent job at this. Rui Maciel
[toc] | [prev] | [next] | [standalone]
| From | Rui Maciel <rui.maciel@gmail.com> |
|---|---|
| Date | 2012-05-28 16:43 +0100 |
| Message-ID | <jq0egj$e3n$2@speranza.aioe.org> |
| In reply to | #1637 |
Rui Maciel wrote: > Since I've started this thread, I've started writing a small Perl script > to generate the models. Perl's support for here-document string literals > appears to do a decent job at this. I've tried to post the script, but it appears that aioe.org doesn't want that to happen. Rui Maciel
[toc] | [prev] | [next] | [standalone]
| From | "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> |
|---|---|
| Date | 2012-05-28 14:45 +0100 |
| Message-ID | <S5CdnRESwOjoH17SnZ2dnUVZ8vednZ2d@bt.com> |
| In reply to | #1633 |
Rui Maciel wrote:
> The objective is to generate a set of files with present different values
> specified by a parameter. For example, let's assume we have this
> template:
>
> <example>
> Line (0,0) (XX,YY)
> </example>
>
> And, based on this template, a user intended to define N different data
> files, each one with different values for (XX, YY), with the values for XX
> and YY being defined in terms of an arbitrary algebraic expression.
Have you considered PHP ? A language I detest, but maybe suitable for your
purpose.
Or just write a little pre-processor in your lanugage of choice (Lisp?) and
have done. It's often quicker and easier to re-invent a wheel than to try to
find the right one in the haystack.
-- chris
[toc] | [prev] | [next] | [standalone]
| From | Rui Maciel <rui.maciel@gmail.com> |
|---|---|
| Date | 2012-05-28 16:21 +0100 |
| Message-ID | <jq056g$jer$2@speranza.aioe.org> |
| In reply to | #1635 |
Chris Uppal wrote: > Have you considered PHP ? A language I detest, but maybe suitable for > your purpose. The thought did crossed my mind, but as I didn't had any PHP interpreter currently installed on my computer, I opted to look for other alternatives. > Or just write a little pre-processor in your lanugage of choice (Lisp?) > and have done. It's often quicker and easier to re-invent a wheel than to > try to find the right one in the haystack. Yes, I've opted for a small Perl script. It may not be the ideal solution, but it does work. How would you do do this sort of task with Lisp? Rui Maciel
[toc] | [prev] | [next] | [standalone]
| From | Patricia Shanahan <pats@acm.org> |
|---|---|
| Date | 2012-05-28 16:33 -0700 |
| Message-ID | <isCdnRqmIM2HllnSnZ2dnUVZ_uadnZ2d@earthlink.com> |
| In reply to | #1638 |
On 5/28/2012 8:21 AM, Rui Maciel wrote: ... > Yes, I've opted for a small Perl script. It may not be the ideal solution, > but it does work. I don't like perl for large programs, but it is a good tool to have around for this sort of task. Patricia
[toc] | [prev] | [next] | [standalone]
| From | Nomen Nescio <nobody@dizum.com> |
|---|---|
| Date | 2012-05-28 16:46 +0200 |
| Message-ID | <2fe8cfc5d188d76ad2c844d6eb2a536e@dizum.com> |
| In reply to | #1633 |
Rui Maciel <rui.maciel@gmail.com> wrote: > Fritz Wuehler wrote: > > > Rui Maciel <rui.maciel@gmail.com> wrote: > > > >> If you were given the task of generating a set of text files whose > >> different versions differed only in a set of numerical values, which tool > >> would you choose? > > > > diff? > > The objective is to generate a set of files with present different values > specified by a parameter. For example, let's assume we have this template: > > <example> > Line (0,0) (XX,YY) > </example> Oh, sorry. In that case m4 might actually work but it's ugly no matter what you do with it. awk is nice because it's more readable and is standard on most UNIX variants. After that I suppose any scripting language you like would do the job well. SNOBOL4 would be a great choice but it can be difficult to learn at first. After that you'll use it for everything. In SNOBOL4 everything is a string until you need it to be something else, like a number. Tcl would be another good choice. It's more work for almost anything than SNOBOL4 but it has the advantage of namespaces and it is easier to write and manage large scripting systems in Tcl. SNOBOL4 becomes difficult to use as a factor of program size. > And, based on this template, a user intended to define N different data > files, each one with different values for (XX, YY), with the values for XX > and YY being defined in terms of an arbitrary algebraic expression. > > > >> The first tool that jumped to my mind was the M4 preprocessor, but it > >> appears it doesn't handle algebraic operations that well. > > > > m4 doesn't seem to do anything well except edit sendmail.cnf files > > After a bit of digging, I also ended up with the idea that m4 is limited to > the point it is essentially useless. Someone correct me if I'm wrong, but > it appears m4 only supports algebraic operations on integers. If it doesn't > support floating point operations, or even decimal fractions, then it is > essentially irrelevant for any task which involves non-integer numberical > values. It's a macro language, it's designed for text replacement but not calculations. I think you can probably force it to do anything but it's not much higher level than brainf**k with a Lisp-like syntax.
[toc] | [prev] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2012-05-29 07:50 +1200 |
| Message-ID | <a2i38sFad7U5@mid.individual.net> |
| In reply to | #1630 |
On 05/28/12 04:29 AM, Rui Maciel wrote: > If you were given the task of generating a set of text files whose different > versions differed only in a set of numerical values, which tool would you > choose? sed? -- Ian Collins
[toc] | [prev] | [standalone]
Back to top | Article view | comp.programming
csiph-web