From: "François Pinard" <pinard@iro.umontreal.ca>
To: emacs-orgmode@gnu.org
Subject: Re: Parsing Org-mode in Python
Date: Mon, 06 Jan 2014 21:33:23 -0500 [thread overview]
Message-ID: <87txdg34i4.fsf@iro.umontreal.ca> (raw)
In-Reply-To: <2014-01-06T11-23-40@devnull.Karl-Voit.at> (Karl Voit's message of "Mon, 6 Jan 2014 11:44:40 +0100")
Karl Voit <devnull@Karl-Voit.at> writes:
> I did not get the impression that [ply] is a parsing engine that is
> done the Python way.
PLY has pros and cons. SPARK[1] always attracted me as being more
elegant. While it accepts a wider set of grammars than PLY, SPARK can
become quite slow on grammars which are less "natural" (admittedly a
very fuzzy, subjective term). For simpler grammars, recursive descent
does the job at good enough speed, and often, grammars can be rearranged
a bit so the lexer could cleverly help the parser. Of course, it looks
like more work writing a recursive descent parser, yet many times in my
experience, the programmer is amply repaid with simplicity and clarity.
>> You don't need a Lisp interpreter written in Python, only Python
>> code that understands org syntax without getting confused.
> if you are going to use a ELISP interpreter to parse Org-mode syntax
> for Python, this should completely re-use the original Org-parser and
> nothing else. I have no idea if this is possible or not. If you have
> to implement a parser on your own, you probably should stick to
> Python-only.
Hey hey, it's fun! :-) You misunderstood me, but this is constructive
actually, as you raise good points. In my dreams, a pure Python parser
parses Org mode files. However, here and there in the parsed files, as
data, we can see bits of Emacs Lisp code, or even Calc syntax at some
places. That Emacs Lisp code could be mere constants or identifiers,
but sometimes more complex, evalable S-expressions.
A parser is probably of limited use if it does not come with some
extra-tools covering most frequent use cases around the syntax, and I
guess that pressure will develop to have some kind of Emacs Lisp
interpreter, hardly complete, probably only mild or even ridiculous.
The interesting idea in your comments is that, *if* we had an Emacs Lisp
interpreter of serious quality, that interpreter could use "the original
Org-parser and nothing else". That would solve maintenance, as the
parser would be wholly external, to be found in Org mode distribution,
all standard. But this avenue is quite unlikely: it looks like a major
undertaking to me, and while such a parser would be useful on small data
excerpts within an Org file, it might be inordinately slow if it had to
interpret a lot of Lisp code while deciphering big Org files.
Worse, keeping a Python parser in sync with the true Emacs Lisp parser
would require much energy, maybe only once in a while, but extended over
a long period of time. Unless a great enthusiasm exists, distributed on
many people, such projects are always doomed to fail. Not many people
are ready to commit themselves for life in the required maintenance.
François
---------------
[1] http://pages.cpsc.ucalgary.ca/~aycock/spark/
next prev parent reply other threads:[~2014-01-07 2:33 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-22 16:37 Converting org-mode/org-contacts to VCard (importing to Android) Karl Voit
2013-11-22 16:54 ` Rüdiger Sonderfeld
2013-11-22 17:09 ` Karl Voit
2013-11-23 0:00 ` Rüdiger Sonderfeld
2013-11-24 13:06 ` Implementing Org-mode tools in languages other than ELISP (was: Converting org-mode/org-contacts to VCard (importing to Android)) Karl Voit
2014-01-04 14:58 ` Implementing Org-mode tools in languages other than ELISP Bastien
2014-01-04 16:43 ` François Pinard
2014-01-05 16:43 ` Daniel Clemente
2014-01-06 10:44 ` Parsing Org-mode in Python (was: Implementing Org-mode tools in languages other than ELISP) Karl Voit
2014-01-07 2:33 ` François Pinard [this message]
2014-01-07 16:09 ` Parsing Org-mode in Python Brett Viren
2014-01-08 12:33 ` François Pinard
2014-01-08 15:42 ` Brett Viren
2014-01-08 16:11 ` François Pinard
2014-01-09 4:13 ` Daniel Clemente
2014-01-09 14:13 ` Brett Viren
2014-01-07 1:47 ` Implementing Org-mode tools in languages other than ELISP François Pinard
2013-11-23 8:36 ` Converting org-mode/org-contacts to VCard (importing to Android) Feng Shu
2013-11-23 8:29 ` Feng Shu
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
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87txdg34i4.fsf@iro.umontreal.ca \
--to=pinard@iro.umontreal.ca \
--cc=emacs-orgmode@gnu.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.savannah.gnu.org/cgit/emacs/org-mode.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).