5G>> HwK2>> 返回
项目作者: JackGoldsworth

项目描述 :
An imperative JVM language created using ANTLR and ASM.
高级语言: Kotlin
项目地址: git://github.com/JackGoldsworth/HwK2.git
创建时间: 2019-06-16T01:26:36Z
项目社区:https://github.com/JackGoldsworth/HwK2

开源协议:Apache License 2.0

下载


HwK Logo



Travis-CI Status


Sonar Status

HwK2

An imperative JVM language that I started using Jakub Dziworski’s tutorial. However, my language is going in a different direction than the original tutorial, so the end results will be quite different. The goal of this language is not to be used, but for me to learn from.

What can be done:

  • Create variables with values and references.
  • Do basic math. (add, subtract, divide, and multiply).
  • Print using variables and values.
  • Functions.
  • Loops.
  • Control statements.

Goal:

This is up for change, but this is currently how I would like the language to look when I decide to stop working on it.

  1. var test = 4
  2. var arrTest = String<5>
  3. fn add(int: x, int: y) -> int {
  4. ret x + y
  5. }
  6. var total = add(test, 3)
  7. arrTest<0> = total.toStr()
  8. print(total)
  9. for(i in [0, 4]) {
  10. print(arrTest<i>)
  11. }

Current Example

  1. var param1 = "Test"
  2. var param2 = 5
  3. var response = testFunc(param1, param2)
  4. print(response)
  5. fn testFunc(String: thing, Int: test) -> String {
  6. print(thing)
  7. print(test)
  8. ret thing
  9. }

Which compiles down to:

  1. public static void main(java.lang.String[]);
  2. descriptor: ([Ljava/lang/String;)V
  3. flags: ACC_PUBLIC, ACC_STATIC
  4. Code:
  5. stack=100, locals=3, args_size=1
  6. 0: ldc #25 // String \"Test\"
  7. 2: astore_0
  8. 3: bipush 5
  9. 5: istore_1
  10. 6: aload_0
  11. 7: iload_1
  12. 8: invokestatic #27 // Method testFunc:(Ljava/lang/String;I)Ljava/lang/String;
  13. 11: astore_2
  14. 12: getstatic #14 // Field java/lang/System.out:Ljava/io/PrintStream;
  15. 15: aload_2
  16. 16: invokevirtual #20 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
  17. 19: return
  18. public static java.lang.String testFunc(java.lang.String, int);
  19. descriptor: (Ljava/lang/String;I)Ljava/lang/String;
  20. flags: ACC_PUBLIC, ACC_STATIC
  21. Code:
  22. stack=100, locals=2, args_size=2
  23. 0: getstatic #14 // Field java/lang/System.out:Ljava/io/PrintStream;
  24. 3: aload_0
  25. 4: invokevirtual #20 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
  26. 7: getstatic #14 // Field java/lang/System.out:Ljava/io/PrintStream;
  27. 10: iload_1
  28. 11: invokevirtual #23 // Method java/io/PrintStream.println:(I)V
  29. 14: aload_0
  30. 15: areturn