没有任何数据可供显示
开源项目社区 | 当前位置 : |
|
www.trustie.net/open_source_projects | 主页 > 开源项目社区 > toupl |
toupl
|
0 | 0 | 2 |
贡献者 | 讨论 | 代码提交 |
Text Oriented Universal Programming Language
Toupl is a super programming language, designed for text generation tasks. Syntax based on Foobar 2000 Tagz Script, but modified and extended for more power, symmetric, easy and generic. Currently supporting generation to:
C++ C# Java JavaScipt ECMAScript Lua PHP Python Visual Basic.
Syntax
Because language designed for text generation, text may be simply outputted as is.
Hello world!Target language variable or expression can be outputted by enclosing in % % tags
Variable var0 is equivalent var0
1+2=%1+2%Target language code can be included by enclosing in ?% %? tags
?%
int i;
int n=100;
while(iNative condition output supported
?%
var _genImage=function(src,alt,width,height)
{
%?
?%
return fpText;
}
?Conditional text putted between [ ] tags and will be outputted if all condition variables inside not null. Conditional variables same as ordinary variables but enclosing by & %& instead % %.
There is a comments
/%
block comment
/
// line comment In situation, when you need output text, that contains elements\tags of toupl,you can enclose this in special ignore tags !% %!
!% all /% this % text ?% outputted ] %!
! even !% you can output !
! if you want to output %!%! - simply twice is %!
Technical details Depends from target language text outputted as append operation to String fpText or to StringBuilder fpStringBuilder (Java and Visual Basic cases). In case of C++ language you can specify work String class (default - std::string). In native condition construction variables tested with bool _fpT(String) function. You must code it.
Command line options
Usage toupl {param:value|"param:value_with_whitespaces"}
Params:
-infile Input file
-outfile Output file or "auto"(cut .toupl extension) else stdout
-lang Input file language or auto (by extension)
List of supported languages:
name
-lang option
JavaScript
javascript
C++
cpp
Java
java
C#
csharp
Python
python
PHP
php
Lua
lua
Visual Basic
vb
C++ Params
-stringclassname Work string class or std::string
Python Params
-indent {s|t}count,s=space,t=tabs
Code generation examples Full syntax test Other tests you can find here
/% minimal test /
?
int i;
int n=100;
while(i
C++
fpText+="\n";
int i;
int n=100;
while(i
Java
fpStringBuilder.append("\n");
int i;
int n=100;
while(i
C#
fpText+="\n";
int i;
int n=100;
while(i
JavaScript
fpText+="\n";
int i;
int n=100;
while(i
Python
fpText+='\n'
int i;
int n=100;
while(i
PHP
int i;
int n=100;
while(iarr[
]=
}
Lua
fpText=fpText.."\n";
int i;
int n=100;
while(i
Visual Basic
fpStringBuilder.Append("" & VbCrLf & "")
int i;
int n=100;
while(i