All Projects → teverett → jvmBASIC

teverett / jvmBASIC

Licence: other
A BASIC to JVM bytecode compiler

Programming Languages

java
68154 projects - #9 most used programming language
basic
69 projects
ANTLR
299 projects

Projects that are alternatives of or similar to jvmBASIC

JavaNewBee
Java 从小白到大牛,涵盖Java 基础、进阶、面试要点等核心要点,助你一臂之力。
Stars: ✭ 84 (+110%)
Mutual labels:  jvm
classfile-rs
JVM classfile parser and writer for Rust
Stars: ✭ 27 (-32.5%)
Mutual labels:  jvm
JavaYouth
主要是Java技术栈的文章,涉及到了源码、原理,面试等知识。如AQS,JVM,rpc,计网,os等等,后续可能会写mysql,redis,zk这些
Stars: ✭ 616 (+1440%)
Mutual labels:  jvm
setup-action
▶️ GitHub Action using Coursier to install JVM and Scala tools
Stars: ✭ 30 (-25%)
Mutual labels:  jvm
java-notes
自己的学习笔记。包含:个人秋招经历、🐂客面经问题按照频率总结、Java一系列知识、数据库、分布式、微服务、前端、技术面试、每日文章等(持续更新)
Stars: ✭ 1,560 (+3800%)
Mutual labels:  jvm
imergindo-jvm-book
Conteúdo do livro do imergindo na JVM
Stars: ✭ 21 (-47.5%)
Mutual labels:  jvm
stuff
All stuff in a single repo (tests, ideas, benchmarks)
Stars: ✭ 13 (-67.5%)
Mutual labels:  jvm
bellsoft-liberica
A Cloud Native Buildpack that provides the Bellsoft Liberica implementations of JREs and JDKs
Stars: ✭ 33 (-17.5%)
Mutual labels:  jvm
LearningNotes
Java学习笔记,主要来源于B站上视频的学习,同时会记录平时一些学习和项目中遇到的问题,同步更新在蘑菇博客,如果对我的博客网站感兴趣的话,欢迎关注我的 蘑菇博客项目 笔记主要涵盖:Java,Spring,SpringCloud,计算机网络,操作系统,数据结构,Vue等 如果笔记对您有帮助的话,欢迎star支持,谢谢~
Stars: ✭ 477 (+1092.5%)
Mutual labels:  jvm
cryostat
Secure JDK Flight Recorder management for containerized JVMs
Stars: ✭ 147 (+267.5%)
Mutual labels:  jvm
java-sdk
一些常用的java sdk和工具类(日期工具类,分布式锁,redis缓存,二叉树,反射工具类,线程池,对称/非对称/分段加解密,json序列化,http工具,雪花算法,字符串相似度,集合操作工具,xml解析,重试Retry工具类,Jvm监控等)
Stars: ✭ 26 (-35%)
Mutual labels:  jvm
play-scala-log4j2-example
An example Play project using Log4J 2 as the logging engine
Stars: ✭ 14 (-65%)
Mutual labels:  jvm
KmLogging
Kotlin multiplatform logging. High performance, composable and simple to use.
Stars: ✭ 21 (-47.5%)
Mutual labels:  jvm
Xposer
A Kubernetes controller to manage (create/update/delete) Kubernetes Ingresses based on the Service - [✩Star] if you are using it!
Stars: ✭ 30 (-25%)
Mutual labels:  expose
dev-feed
Flutter-based mobile app displaying a list of daily curated content from top engineering blogs and articles. Backed by a GraphQL-based API written in Kotlin..
Stars: ✭ 20 (-50%)
Mutual labels:  jvm
play-java-seed.g8
Play Java Seed template: use "sbt new playframework/play-java-seed.g8"
Stars: ✭ 20 (-50%)
Mutual labels:  jvm
rust-jvm
A toy JVM on Web Browser implemented by Rust
Stars: ✭ 59 (+47.5%)
Mutual labels:  jvm
xoom-cluster
The VLINGO XOOM platform SDK cluster management for Reactive, scalable resiliency of JVM tools and applications running on XOOM LATTICE and XOOM ACTORS.
Stars: ✭ 25 (-37.5%)
Mutual labels:  jvm
metrics-agent
JVM agent based metrics with Prometheus and Dropwizard support (Java, Scala, Clojure, Kotlin, etc)
Stars: ✭ 25 (-37.5%)
Mutual labels:  jvm
kpspemu
PSP Emulator written in Kotlin for JVM, JS and Native. Can work as PWA.
Stars: ✭ 57 (+42.5%)
Mutual labels:  jvm

CI Codacy Badge

jvmBASIC

A BASIC to JVM bytecode compiler

jvmBASIC is a bytecode compiler which is capable of consuming a BASIC file (.bas) and producing a JVM .class file. The JVM class file exposes a public class named after the input file and a public method "program()" which contains the generated bytecode. The generated .class file also exposes a "void main()" method which enables the BASIC program to be run from the command line.

In order to use the generated .class file from Java code, the public class members "inputStream" and "outputStream" must be set, in order for the BASIC program to consume input and produce output.

Maven Coordinates

jvmBasicCC

<groupId>com.khubla.jvmbasic</groupId>
<artifactId>jvmbasicc</artifactId>
<version>2.4.0</version>
<packaging>jar</packaging>

jvmBasicRT

<groupId>com.khubla.jvmbasic</groupId>
<artifactId>jvmbasicrt</artifactId>
<version>2.4.0</version>
<packaging>jar</packaging>

License

jvmBASIC is distributed until the GPL v3. For more information please see the GPL.

Modules

The modules are:

  • jvmBasicc - The jvmBASIC compiler
  • jvmBasicrt - the jvmBASIC runtime library
  • jvmBasicwww - A simple web server that uses BASIC programs to generate HTML over HTTP
  • jvmBasicmojo - A maven mojo that compiles all .bas files found at /src/main/basic to .class files
  • examples - a simple directory of examples
  • demo - a simple .BAS program which can be compiled to produce a .jar and run to produce output

The Implementation

Notes on the implementation

  • The Parser and Lexer are created by ANTLR via an ANTLR grammar.
  • The generated bytecode is created by ObjectWeb ASM
  • Currently screen functions such as "CLEAR" are not implemented
  • Math functions and string functions are implemented in the jvmBasic runtime jar "jvmbasicrt.jar"
  • BASIC types are implemented by the class "Value" in jvmbasicrt.jar

Running an example

  • build jvmBASIC: mvn clean package install
  • use the script run_bas.sh to run an example:
sh run_bas.sh hellojvmBASIC.bas

The output should look very much like:

shrek:jvmBASIC tom$ sh run_bas.sh hellojvmBASIC.bas 
Running BASIC file hellojvmBASIC.bas
khubla.com jvmBASIC Compiler
Compiling: /Users/tom/projects/jvmBASIC/hellojvmBASIC.bas
added manifest
adding: hellojvmBASIC.class(in = 1402) (out= 740)(deflated 47%)
19:17:44.698 [main] INFO com.khubla.jvmbasic.jvmbasicrt.ExecutionContext - pushing String: '"hello from jvmBASIC"'
19:17:44.701 [main] INFO com.khubla.jvmbasic.jvmbasicrt.ExecutionContext - popping hello from jvmBASIC
hello from jvmBASIC
shrek:jvmBASIC tom$ 

Using jvmBASICC

jvmbasicc.jar is the jvmBASIC compiler. The only required parameter is -file, which is used to specify an input file. For example to compile "myprogram.bas" to bytecode:

java -jar jvmbasicc.jar -file myprogram.bas

This will produce "jvmbasicc.class"

Once jvmbasicc.class has been combined into a jar file, the file "jvmbasicrt.jar" must be on the class path order order to run the generated code.

Running java -jar jvmbasicc.jar will produce help output, which will show all the commandline options.

The generated bytecode

Inspecting the generated bytecode

To view the generated class at the command line, use javap. For example to view the generated output for "bottlesofbeer.bas" type

javap botttlesofbeer

to produce more verbose output from javap use

javap -c bottlesofbeer

The grammar

The ANTLR grammar is at

https://github.com/teverett/jvmBASIC/blob/master/jvmbasicc/src/main/antlr4/com/khubla/jvmbasic/jvmbasicc/antlr/jvmBasic.g4

There is an excellent ANTLR grammar editor here:

ANTLRWorks

Once you have created the grammar you need, recompile jvmBasicc:

mvn clean package

If you wish to use jvmBasicMojo, you will have to install the generated jvmBasic compiler:

mvn clean package install

Running the Examples

The examples are standard maven builds, and require the jvmBASIC maven mojo "jvmBasicmojo". In order for the examples to work propertly jvmbasicc.jar, jvmbasicrt.jar and jvmbasicmojo.jar must all have been compiled and installed. The easiest way to do this is to run this command from the root jvmBasic directory

mvn clean package install

To use the jvmBasic maven moojo from the command line:

mvn clean jvmbasic:jvmbasic jar:jar

This will build the BASIC files, and produce a jar that can be run from the command line. jvmbasicrt.jar must be on the command line.

jvmBASIC WWW

jvmBASIC WWW is a very simple web server that produces HTML output from BASIC files. To run it use a command line similar to this:

java -jar target/jvmbasicwww.jar -sourcedir www -classdir www/classfiles/ -port 8080

The basic files to compile are the directory specified by -sourcedir and the generated classes are in the directory specified by -classdir. The HTTP port to bind is specified by -port. The default page is served by INDEX.bas.

to run the example use:

sh run.sh and point your browser to http://localhost:8080/

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].