100% Java compatibility and Functional Programming.
MIT License
Latte is a JVM language. It's highly readable and extensible.
Syntax Mannual (NEW) Latte WebSite
Atom
Extensions :
atom-latte-lang-highlighting atom-latte-lang-ide
Gradle
Plugin :
Latte
is based on java 6. It's compiled to JVM byte code, and can collaborate with any java library.
JDK 1.6
or higher is the only thing required.
The project is managed by Gradle
, you can use Gradle 2.12
(or higher) to build automatically
A build script is also provided.
clone the repository, and run
./build.py
You will get a shell scripts. The shell scripts can help you run the repl
.
The build script does not support windows. Please follow the order (latte-[class-recorder | compiler | gradle-plugin | library | build]) to run
gradle clean latteBuild
in each directory, then extractbuild/distributions/latte-${version}.zip
in modulelatte-build
, the shell script is in thebin
directory.
run:
./latte
then the REPL starts
Welcome to Latte lang
Type in expressions and double Enter to have them evaluated.
Type :help for more information.
for syntax help, please visit https://github.com/wkgcass/Latte-lang/
lt> 1+1
|
res0 : java.lang.Integer = 2
lt>
lt
FilesThere are two ways of compiling lt
files
use program command
latte -c <source-directory>
the detailed commands and options can be found in
latte -help
or:
start the REPL
interpreter, and construct a Compiler
compiler = Compiler()
use >>
operator to specify output directory
compiler >> '...'
// or
compiler >> File('...')
use +
operator to add class-path
compiler + '...'
use compile MAP
to specify source codes to be compiled and start compiling
compiler compile ['fileName':FileObject]
usually filesInDirectory('...', regex)
is used, e.g.
compiler compile filesInDirectory('...', '.\*\\.lt'.r)
these method invocations can be chained up
Compiler() + '...cp...' >> '...output...' compile filesInDirectory('...source...', '.\*\\.lt'.r)
You can write a script
to configure the settings. Check build.lts.template for more info.
you can run a script directly
latte -s script-location script-arguments...
or:
start the REPL
interpreter
type :script <script file>
and Enter
then use script run
or script run ['string array']
to run the script
Latte-lang supports JSR 223 specification. Use getEngineByName("Latte-lang")
to retrieve the scripting engine.
ScriptEngine engine = new ScriptEngineManager().getEngineByName("Latte-lang");
Object result = engine.eval("a = 1 + 3");
System.out.println(engine.get("a"));
Since Latte-lang is a compiling language, and it's directly compiled to JVM byte code, you could even use the scripting engine in Latte source codes.
engine = ScriptEngineManager().getEngineByName("Latte-lang")
result = engine eval "a = 1 + 3"
.println result
.println engine.a
A plugin for Gradle
is provided, which helps you compile latte source codes.
add the plugin configuration:
buildscript {
dependencies {
classpath 'org.latte-lang:latte-gradle-plugin:$VERSION'
}
}
apply plugin: 'latte'
sourceSets {
main {
java
latte.srcDirs = ['src/main/latte']
resources
}
test {
java
latte
resources
}
}
latteConfig {
afterJava = true
afterGroovy = false
fastFail = false
}
all configurations are optional
The plugin adds compileLatte
and compileTestLatte
tasks, where compileLatte
is before classes
task, and compileTestLatte
is before testClasses
task
create a folder named latte
in the same parent directory. The directory tree should be:
src
main
java
\*.java ; java source
latte
\*.lt ; latte source
resources
\*.lts ; latte scripts
other resources
test
java
\*.java
latte
\*.lt
resources
\*.lts
other resources
run
gradle clean jar
visit the Latte WebSite
or read the mannual
LatteJVM
Atom
:
atom-latte-lang-highlighting atom-latte-lang-ide
Gradle
Plugin :
Latte
java6JVMJava
JDK 1.6
Gradle
Gradle 2.12
() Build
Build
clone,
./build.py
shell, shellrepl
.
windowslatte-[class-recorder | compiler | gradle-plugin | library | build]
gradle clean latteBuild``latte-build``build/distributions/latte-${version}.zip
binshell
:
./latte
, REPL
Welcome to Latte lang
Type in expressions and double Enter to have them evaluated.
Type :help for more information.
for syntax help, please visit https://github.com/wkgcass/Latte-lang/
lt> 1+1
|
res0 : java.lang.Integer = 2
lt>
lt
latte -c <source-directory>
latte -help
:
REPL
, Compiler
compiler = Compiler()
>>
compiler >> '...'
// or
compiler >> File('...')
+
class-path
compiler + '...'
compile MAP
compiler compile ['fileName':FileObject]
filesInDirectory('...', regex)
, e.g.
compiler compile filesInDirectory('/Users/me/src', '.\*\\.lt'.r)
Compiler() + '...cp...' >> '...output...' compile filesInDirectory('...source...', '.\*\\.lt'.r)
script
build.lts.template
latte -s script-file-path script-arguments...
REPL
:script <script file>
script run
script run ['string array']
Latte-langJSR223getEngineByName("Latte-lang")``ScriptEngine
ScriptEngine engine = new ScriptEngineManager().getEngineByName("Latte-lang");
Object result = engine.eval("a = 1 + 3");
System.out.println(engine.get("a"));
Latte-langJVMLatte
engine = ScriptEngineManager().getEngineByName("Latte-lang")
result = engine eval "a = 1 + 3"
.println result
.println engine.a
Gradle
latte
script
gradle plugin
buildscript {
dependencies {
classpath 'org.latte-lang:latte-gradle-plugin:$VERSION'
}
}
apply plugin: 'latte'
sourceSets {
main {
java
latte.srcDirs = ['src/main/latte']
resources
}
test {
java
latte
resources
}
}
latteConfig {
afterJava = true
afterGroovy = false
fastFail = false
}
compileLatte
compileTestLatte
compileLatte
classes
, compileTestLatte
testClasses
latte
src
main
java
\*.java ; java source
latte
\*.lt ; latte source
resources
\*.lts ; latte scripts
other resources
test
java
\*.java
latte
\*.lt
resources
\*.lts
other resources
gradle clean jar