2 releases
0.1.1 | Mar 25, 2023 |
---|---|
0.1.0 | Mar 25, 2023 |
#1513 in Development tools
44 downloads per month
11KB
219 lines
Pollen programmming language
A programming language with XML syntax. Scripts are a series of complex instructions provided by the runtime. New element tags can be added to the runtime by using general purpose plugins.
An HTML template is an HTML model. Templates are preformatted HTML in which text or image content can be inserted into. Most modern template languages have some form of programming in them. Pollen also does that but it reuses the XML systax for that, without having to create a whole new syntax. Therefore new programmers can feel familiarized with the Pollen language right on the beggining of learning on how to code on it.
XML tags represent the data structure and contain metadata.
The original idea was to create a Common Gateway Interface (CGI) executable and an Apache module. Something like PHP. But instead of interpreting a script, Pollen would load a compiled dynamic library. It provides a simple templating engine while keeping the speed of compiled languagues.
The Apache Runtime Library (APR) is being added to ensure good security. APR provides dynamic arrays and memory pools to mitigate use-after-free, buffer overflows and buffer underflows. A good explanation can be found here.
libpollen provides common functions which are independent from the templatizer runtime executable. Plugins use libtemplatizer for code reuse.
Plugins
In computing, a plug-in (or plugin, add-in, addin, add-on, or addon) is a software component that adds a specific feature to an existing computer program. When a program supports plug-ins, it enables customization.
Input plugins read url-encoded and JSON input from the client. Those values are then used in a script using the '@' symbol. Input plugins can be selected using the 'templatizer' tag.
Dynamic Linker plugins can be used to load programs written in specific programming languages. The plugin is specified using the 'lib' attribute on the 'templatizer' element. The template can set plugin arguments using the 'args' XML attribute.
A linker called ld-exec.so can be used to run binary programs or text scripts that begin with a shebang on Linux.
Some plugins are full web apps. Text placeholder variables are set using variable names and those variables can be used on XHTML template placeholders. Different websites can have different user interfaces while using the same Templatier app plugin.
Example
The following is an example of a program written in Pollen. It prints hello world comming from two Pollen plugins written in different languages. Note that the Pollen syntax this example as well as other Pollen programs were intentionaly made to be similar to XML syntax.
<!-- Copyright (C) 2023 Mateus de Lima Oliveira -->
<templatizer lib="../plugins/input/in_helloworld.so">
<templatizer lib="../plugins/input/helloworld-rs/target/release/libhelloworld_rs.so">
<templatizer lib="../plugins/net/headers.so">
<html>
<head>
<meta charset="UTF-8"/>
<title>Hello world pipeline</title>
</head>
<body>
<h1>Hello world pipeline</h1>
<p>Hello world Templatizer pipeline in multiple programming languages:</p>
<ul>
<li>C: <span>@</span></li>
<li>Rust: <span>@</span></li>
</ul>
<p>Have a nice day!</p>
<templatizer lib="../plugins/net/copyright.so">
<p>@</p>
</templatizer>
</body>
</html>
</templatizer>
</templatizer>
</templatizer>
More tests and examples can be found in the tests directory of this source tree.
Compiling from source
Pollen was only tested on Linux.
It requires:
- sys/queue.h for list macros (installed by default on most Linux distributions);
- libdl for dynamically loading libraries (installed by default on most Linux distributions);
- build-essential
- libexpat1-dev;
- flex and bison;
- libapr1-dev;
- libvirt-dev;
- liblmdb-dev;
- ldc;
- cargo;
- rustc;
- valgrind;
- llvm-dev.
root@debian:~# make dependencies
mateus@debian:~$ make
mateus@debian:~$ make test
root@debian:~# make install
Termux
Compile Pollen for termux with:
mateus@debian:~$ make termux
root@debian:~# make install
Debug
Enabling debug can be done by setting the DEBUG environment variable to "y":
mateus@debian:~$ DEBUG=y make
Development roadmap
The following is my future development:
- Convert Quick to a series daemons
- Remove autotools from Quick
- Merge Quick with Pollen
- Fix bugs
Contributing
If you like this project, please consider making a donation to help me develop it further. :)