modified example programs, added strings to lexer
git-svn-id: svn://anubis/jtlc/trunk@6 f5bc74b8-7b62-4e90-9214-7121d538519f
This commit is contained in:
1 parent
e83a2f1f08
commit
bb982b62b8
5 files changed
+41
-7
No files matched your search
@@ -1,7 +1,7 @@
|
||||
|
||||
import std.io.*;
|
||||
|
||||
int main(args : String[])
|
||||
public main(args : String[]) : int
|
||||
{
|
||||
foreach (arg <- args)
|
||||
println("arg: ", arg);
|
||||
|
||||
@@ -5,7 +5,7 @@ import std.io.*;
|
||||
|
||||
typedef function double (double) interpolator_t;
|
||||
|
||||
int main(args : String[])
|
||||
public main(args : String[]) : int
|
||||
{
|
||||
interpolator_t i1 = getInterpolator(1, 5, 4);
|
||||
interpolator_t i2 = getInterpolator(10, 2, 5);
|
||||
@@ -26,7 +26,7 @@ int main(args : String[])
|
||||
* Create and return a linear interpolator functor which interpolates
|
||||
* between (0.0, x1) and (sep, x2), returning the output y-value
|
||||
*/
|
||||
interpolator_t getInterpolator(x1 : double, x2 : double, sep : double)
|
||||
private getInterpolator(x1 : double, x2 : double, sep : double) : interpolator_t
|
||||
{
|
||||
assert (sep > 0.0);
|
||||
|
||||
|
||||
+3
-4
@@ -3,7 +3,7 @@ module Regex;
|
||||
|
||||
import std.io.*;
|
||||
|
||||
int main(args : String[])
|
||||
public main(args : String[]) : int
|
||||
{
|
||||
foreach (arg <- args)
|
||||
{
|
||||
@@ -20,15 +20,14 @@ int main(args : String[])
|
||||
{
|
||||
println(arg, " is a number");
|
||||
}
|
||||
else if (arg =~ "/^0x\d+$/i")
|
||||
else if (arg =~ "/^0x[0-9a-fA-F]+$/i")
|
||||
{
|
||||
println(arg, " is a hexadecimal number");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* auto declaration of matches to be of type String[] */
|
||||
matches ::= arg =~ "/(.)(.)/";
|
||||
if (matches)
|
||||
if (matches ::= arg =~ "/(.)(.)/")
|
||||
{
|
||||
println("first character: ", matches[0],
|
||||
"second character: ", matches[1]);
|
||||
|
||||
Reference in new issue
Block a user