ocaml / mpp-language-blender Goto Github PK
View Code? Open in Web Editor NEWMPP: a meta preprocessor that blends programming languages
MPP: a meta preprocessor that blends programming languages
Sometimes (not always) MPP dies on errors and errors messages are mute, well they shouldn't be. ==> let error messages be!
At the minimum, we need the following:
Thanks! This would make it much easier to use MPP.
Currently in Opam it says:
depends "ocaml" {>= "4.03" & < "5.0.0"} "dune" {> "1.11.0"} "stdlib-shims"
{{! ifdef foo something !}}
{{! else
something else
!}}
is invalid because the else
command is lexed as "else\n"
. it seems newline is a valid character in an indentifier and does not count as whitespace. This isn't intuitive.
It seems src/lib
is unnecessary and misnamed. The library is actually all directly under src
.
elseifdef
doesn't work. https://github.com/ocaml/MPP-language-blender/blame/master/README.md#L21 says it exists but https://github.com/ocaml/MPP-language-blender/blob/master/src/mpp_actions.ml#L341 seems to have it disabled.
I want to do:
mpp -set x=true foo.mpp
mpp -set x=false foo.mpp
and then in foo.mpp
, do something like
{{if (( get x )) = true
Got true.
}}
{{if (( get x )) = false
Got false.
}}
Is there some way to do the above?
I broke the compatibility with ocaml < 4.02.0
I'll fix that... hopefully for version 0.2.1
Generating
"foo
#42 "bar.ml"
baz"
is not helpful...
Well, it's easier said than done.
Perhaps just allow the use of different foreign languages with possibility to set a target language for each of them. It'd certainly be less twisted...
(I'm simply copy-pasting the content of the file ideas_draft.md
as I'm in the process of cleaning the repo)
Currently, what is between the opening token and the first following
space is the name of the block. I'm wondering how bad it would be, in
order to avoid that "mandatory space", to consider that names can't be
builtin names. That would allow the space to be optional.In this context, it would mean that builtin names are sort of keywords...
Latest version(s) of MPP print locations when using foreign code blocks, and it makes it easier to track errors. But the locations disappear after the foreign code has been evaluated. Evaluation of the foreign code should print source locations. However it's not as trivial as saying it: the format of the location depends on the final language, not the 1st nor the 2nd. But, it should be not too hard to make a version that works with CPP locations. This will probably bump MPP version to 0.2.x. as it will need a few changes in the interface.
and is necessary for pinning
Is there a library function corresponding to the main app's functionality? As far as I can tell, it is within mpp_main.ml
but not exposed as a callable function. I would like to have the main functionality available with strings as the input/output, rather than files. This would allow more efficient processing in external scripts and avoid having to make messy system calls.
Consider you have a file in a directory called src/ with the following contents:
$ cat src/foo.mpp
(( input bar.txt ))
Currently, the file bar.txt
is searched relative to the current working directory of whatever process you're calling mpp from. I think it would be more intuitive if the path was interpreted as relative to src/, i.e. the directory in which the mpp file resides.
One issue with this is related to my request in #7 for a library function corresponding to the command line app. If you provide a function val mpp_on_string : string -> string
, which directly operates on a string, then you don't have a file path to get the parent directory from. A solution could be to have such a function also take an optional filename
argument. If this argument is not provided, then you fallback to using the current working directory.
It happens sometimes with mpp.0.1.0
.
From the root of the ocaml.org repository, the following command
mpp -so '((!' -sc '!))' -son '{{!' -scn '!}}' -soc '' -scc '' -sec '' -sos '{{<' -scs '>}}' -its template/main.mpp -o /tmp/c.html -set "filename=x" -set "page=/tmp/preprocessed_99problems.html"
terminates with the exception Stack_overflow
where /tmp/preprocessed_99problems.html
is the result of processing the file site/learn/tutorials/99problems.md
with omd.
If I run
mpp -so '((!' -sc '!))' -son '{{!' -scn '!}}' -soc '' -scc '' -sec '' -sos '{{<' -scs '>}}' -its -set "filename=site/index.md" -set "page=ocaml.org/index.html.tmp" tpl/main.mpp -o "ocaml.org/index.html"
in a terminal, I get
sh: 1: Syntax error: redirection unexpected
The strings are properly escaped. Is it possible that the problem comes from mpp trying to execute commands and not escaping properly the arguments? (No time to investigate right now)
When mpp
is used in scripts, it is not always clear what the origin of an error is. Thus MPP should identify itself in error messages.
The bash
language output uses echo
, so it adds new-lines.
{
cat <<EOF
hello {< printf "world" >}!
EOF
} | mpp -l bash | bash
gives
hello
world!
Instead of echo ...
it could use printf '%s' ...
(it's POSIX sh
).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.