[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] Babel: filtering code to produce another block
From: |
Jarmo Hurri |
Subject: |
[O] Babel: filtering code to produce another block |
Date: |
Wed, 13 Sep 2017 11:34:17 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) |
Greetings.
This question can again be described shortly and in more detail.
1. Short form: what would be a convenient way to filter the source
code in a Babel source code block so that the output would be the
source code in another block?
2. Then the long form. I need to emulate the very basics of one
programming language, namely Processing
https://processing.org/
with another, namely Asymptote
http://asymptote.sourceforge.net/
This is to be done within Org. I need to do this to illustrate on
paper the visual output of simple, static (no animation) Processing
programs.
Making this work roughly isn't too difficult, because these two
languages have very similar syntaxes. For example, provided that a
function rect() has been implemented in Asymptote, the following
code is legit in both Processing and Asymptote:
#+name: pic
#+BEGIN_SRC asymptote
size (800, 600);
for (int i = 0; i < 10; i += 2)
rect (i * 10, i * 20, 30, 10);
#+END_SRC
After this block has been defined I can show it as "Processing
code" and draw a picture with Asymptote, using noweb if need be. It
is also easy to use transforms so that the coordinate systems of
the two languages match. Furthermore, typedef can be used to align
some variable type differences.
However, my current issue is dealing with 'final' in Asymptote. The
following is not legit Asymptote code:
#+BEGIN_SRC asymptote
size (800, 600);
final int S = 20;
rect (100, 100, S, S);
#+END_SRC
It would be legit if the word 'final' were simply removed. Which
brings me to the question: what would be an easy way to filter this
block to produce another block? The header arguments of the two
blocks would be different from each other.
Thanks in advance,
Jarmo
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [O] Babel: filtering code to produce another block,
Jarmo Hurri <=