Mercurial Hosting > nabble
view src/nabble/naml/namespaces/IntegerNamespace.java @ 62:4674ed7d56df default tip
remove n2
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sat, 30 Sep 2023 20:25:29 -0600 |
parents | 7ecd1a4ef557 |
children |
line wrap: on
line source
package nabble.naml.namespaces; import nabble.naml.compiler.Command; import nabble.naml.compiler.CommandSpec; import nabble.naml.compiler.IPrintWriter; import nabble.naml.compiler.Interpreter; import nabble.naml.compiler.Namespace; import nabble.naml.compiler.Primitive; @Namespace ( name = "integer", global = false, transparent = true ) public final class IntegerNamespace implements Primitive { private int i; public IntegerNamespace(int i) { this.i = i; } public String toString() { return Integer.toString(i); } private static final CommandSpec I = new CommandSpec.Builder() .dotParameter("i") .build() ; public static final CommandSpec plus = I; @Command public void plus(IPrintWriter out,Interpreter interp) { out.print( i = i + interp.getArgAsInt("i") ); } @Command public void value(IPrintWriter out,Interpreter interp) { out.print(i); } public static final CommandSpec minus = I; @Command public void minus(IPrintWriter out,Interpreter interp) { out.print( i = i - interp.getArgAsInt("i") ); } public static final CommandSpec is_greater_than = I; @Command public void is_greater_than(IPrintWriter out,Interpreter interp) { out.print( i > interp.getArgAsInt("i") ); } public static final CommandSpec is_greater_than_or_equal_to = I; @Command public void is_greater_than_or_equal_to(IPrintWriter out,Interpreter interp) { out.print( i >= interp.getArgAsInt("i") ); } public static final CommandSpec is_less_than = I; @Command public void is_less_than(IPrintWriter out,Interpreter interp) { out.print( i < interp.getArgAsInt("i") ); } public static final CommandSpec is_less_than_or_equal_to = I; @Command public void is_less_than_or_equal_to(IPrintWriter out,Interpreter interp) { out.print( i <= interp.getArgAsInt("i") ); } @Command public void one(IPrintWriter out,Interpreter interp) { out.print( 1 ); } }