-
Notifications
You must be signed in to change notification settings - Fork 0
lifus/wordy
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
== What's this? This is realization of small dsl, that targeted to work with lists(vectors). ANTLR (http://www.antlr.org/), string templates (http://www.stringtemplate.org/) and Jasmine language was used here. == 'Features' of dsl types: -Void (only for functions) -List -String statements: -foreach -if -while -return -assign structure of program: -blocks are distinguished, similar to python (tabs/whitespaces) -only possible entry point, similar to c (Void main()) -you could call another functions, no mater where thay are - before or after current function -functions could return values -functions could take parameters -nested scopes of variables (shadowing works) error reporting: -syntax errors reporting -semantic errors reporting -console output -boolean expressions -list manipulation == Whats going on here? Roughly: Input file -> Lexical Analyzer(antlr) -> Token Stream -> Syntax Parser(antlr) -> AST -> Semantic Analyzer -> Template generator(String template) -> Target Code generator(Jasmine) -> Jar file Take a look at src/Tool.java == Structure |-- src // All sorces | |-- templates // String template |-- src | |-- files // Examples of syntax | |-- output // Produced jar files |-- bin // Ready jar file |-- lib // Necessary libs == Usage $ java -jar wordy.jar [-debug] <path_to_file> Options: -debug Print syntax tree If file would compile successfully, you will found jar file, you could execute it: $ java -jar <path_to_file>.jar == Notes When creating jar file in eclipse, do the following: File->Export->Java->Runnable JAR file Then choose 'package required libraries into generated JAR'. It will make single portable jar == Afterword I wrote that code a year ago. Its not very clean. But i think it could be helpful for anyone, who starts to learn antlr, want to use AST, string templates. Also, read the Terence Parr's 'The Definitive ANTLR Reference'. Great book, it will explain you how to do some cool stuff with ANTLR
About
ANTLR realization of small dsl, that targeted to work with lists(vectors)
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published