[texhax] Little Languages and diaries
marchywka at hotmail.com
Sat May 19 22:10:01 CEST 2018
I probably hijacked the thread a bit but generally I'm trying to use a tex document as
a source for both human readable ( run with latex ) and machine readable ( custom
parser ) data. I needed something simple to collect data - in this case diet history.
This may sound great for a DB and GUI but even with a limited selection
of items there were always events that would be hard to add into a menu
and it was just easier to use vi than to keep escaping into a free form text box lol.
In this case common choices are in a template and I just delete those that do not
apply and add anything unique. I suppose this would also work in a csv file
but the tex document does let me add notes that the parse can learn about later.
So, the tex document seemed ideal as a data file if the structured primitive prose
would be suitable for human consumption. Error detection during entry is a bit
lacking although vim macro are pretty appealing but even there running the
c++ parser every few days or weeks turns up stuff that ends up being easier to fix in a batch mode.
So far CSV files have been enough although while XML is appealing I'd probably go to JSON
for much of this now.
The OP was probably considering this which differs a bit from my interests here although this paradigm
is great for many things including typesetting :) Personally I've tried to adopt this idea for many
c++ things- the compiled code implements to domain specific tasks and the interpreted language
stings them all together.
A little language is a domain-specific language designed to be very small and focussed on doing just what the designers of it had in mind. The term comes from Little Languages, Programming Pearls, Jon Benley, Communications of the ACM 29:8 (August 1986), pp. 711-721. He points out that much of what we do as programmers can be thought of as creating "little languages" that are suited to particular small tasks.
DKF: It is the Tcl experience that little languages tend to grow. After all, that's what Tcl started out as: a common little language for John Ousterhout's EDA tools.
From: William F Hammond <hmwlfsr at yahoo.com>
Sent: Saturday, May 19, 2018 3:30 PM
To: Mike Marchywka
Cc: Gordon Haverland; texhax
Subject: Re: [texhax] Little Languages and diaries
Mike Marchywka <marchywka at hotmail.com> writes:
> I'm not entirely sure what little languages are but I have
> been using tex to create a diet diary that I later need to
> parse and graph. There is no money involved but vitamins
> coudl just as easily be money...
> So, I have to be consistent about my nominally free form
> entries. I enter them into a tex table rather than a csv
> file since that is my primary "lab notebook" document. I
> ended up picking a simple adjective-noun restriction, a
> simple macro syntax and wrote c++ code to parse it but was
> curious if there is a general solution somewhere.
> This has worked well compared to taking each day's meal
> notes and trying to use a GUI to put them into a DB and
> then get them back out etc. The c++ parse picks up entry
> errors as well as a GUI and has other benefits. In theory
> I could enter them into a cell phone in the kitchen but I
> just use "vi" on a laptop. I think I asked about this on
> some other forum but got no responses.
Since I have not seen an example of what you want to
process, this response may be off point.
When you say "general solution", I take that to suggest a
library (for C++, Java, Python, or whatever) which organizes
the task of writing the code to parse. In that direction I
would be inclined to think about (1) translating the source
into your own custom SGML document type, (2) morphing that
in a more or less canonical way to an XML shadow document
type, and then (3) using one of the XML libraries for your
favorite language to reach the desired end format.
Depending on the nature of your source, it might be easily
possible to go directly from that to an XML document type.
Email: hmwlfsr chez yahoo
or: gellmu chez gmail
</marchywka at hotmail.com></hmwlfsr at yahoo.com>
More information about the texhax