Browse files

drop support for single quoted strings from stage 0

  • Loading branch information...
1 parent 8c41858 commit 01b5c40a45667b8f3bc2a5dc6ab693efa858ea81 @NotFound committed May 24, 2012
Showing with 1,093 additions and 1,134 deletions.
  1. +1 −1 t/basic/00test.t
  2. +3 −3 t/basic/01int.t
  3. +14 −14 t/basic/01intarray.t
  4. +11 −20 t/basic/01string.t
  5. +16 −16 t/basic/01stringarray.t
  6. +12 −12 t/basic/02arrayexpr.t
  7. +6 −6 t/basic/02bitwisetops.t
  8. +12 −12 t/basic/02hashexpr.t
  9. +8 −8 t/basic/02predefuncs.t
  10. +3 −3 t/basic/03functions.t
  11. +17 −17 t/basic/04for.t
  12. +2 −2 t/basic/04switch.t
  13. +18 −18 t/basic/05new.t
  14. +37 −37 t/harness
  15. +10 −10 t/instanceof.t
  16. +12 −1 t/medium/01string.t
  17. +3 −3 t/parent.t
  18. +1 −1 t/self.t
  19. +6 −6 t/test.t
  20. +2 −2 t/throw.t
  21. +6 −6 t/var.t
  22. +2 −2 t/vtable.t
  23. +2 −43 token.cpp
  24. +1 −3 token.h
  25. +86 −86 winxed.winxed
  26. +1 −1 winxedst0.cpp
  27. +801 −801 winxedst1.winxed
View
2 t/basic/00test.t
@@ -9,7 +9,7 @@ function main()
{
plan(1);
- ok(1, 'plan and ok works');
+ ok(1, "plan and ok works");
}
// End
View
6 t/basic/01int.t
@@ -9,12 +9,12 @@ function main()
plan(3);
int i = 42;
- is(i, 42, 'simple initializer');
+ is(i, 42, "simple initializer");
int j;
j = 69;
- is(j, 69, 'simple assignment');
+ is(j, 69, "simple assignment");
i = 0xFE;
- is(i, 254, 'hex integer');
+ is(i, 254, "hex integer");
}
// End
View
28 t/basic/01intarray.t
@@ -9,29 +9,29 @@ function main()
plan(14);
int noinit [];
- ok(noinit instanceof 'ResizableIntegerArray', 'type of non initialized');
- is(elements(noinit), 0, 'size of non initialized');
+ ok(noinit instanceof "ResizableIntegerArray", "type of non initialized");
+ is(elements(noinit), 0, "size of non initialized");
int a []= [ 7, 42 ];
- ok(a instanceof 'ResizableIntegerArray', 'type of initialized');
- is(elements(a), 2, 'size of initialized');
- is(a[0], 7, 'first value');
- is(a[1], 42, 'second value');
+ ok(a instanceof "ResizableIntegerArray", "type of initialized");
+ is(elements(a), 2, "size of initialized");
+ is(a[0], 7, "first value");
+ is(a[1], 42, "second value");
int b [2];
- ok(b instanceof 'FixedIntegerArray', 'type of non initialized with size');
- is(elements(b), 2, 'size of non initialized with size');
+ ok(b instanceof "FixedIntegerArray", "type of non initialized with size");
+ is(elements(b), 2, "size of non initialized with size");
int c [2] = [ 7, 42 ];
- ok(c instanceof 'FixedIntegerArray', 'type of initialized with size');
- is(elements(c), 2, 'size of initialized with size');
- is(c[0], 7, 'first value');
- is(c[1], 42, 'second value');
+ ok(c instanceof "FixedIntegerArray", "type of initialized with size");
+ is(elements(c), 2, "size of initialized with size");
+ is(c[0], 7, "first value");
+ is(c[1], 42, "second value");
int size= 4;
int d[size];
- ok(c instanceof 'FixedIntegerArray', 'type of non initialized with size non constant');
- is(elements(d), size, 'size of non initialized with size non constant');
+ ok(c instanceof "FixedIntegerArray", "type of non initialized with size non constant");
+ is(elements(d), size, "size of non initialized with size non constant");
}
// End
View
31 t/basic/01string.t
@@ -6,38 +6,29 @@ using extern Test.More plan, is;
function main()
{
- plan(11);
+ plan(6);
string r;
- string s1= 'a';
- string s2= 'b';
- string s3= 'c';
- string s4= 'd';
+ string s1= "a";
+ string s2= "b";
+ string s3= "c";
+ string s4= "d";
// Concatenation
r = s1 + s2;
- is(r, 'ab', 'concat 2');
+ is(r, "ab", "concat 2");
r = s1 + s2 + s3;
- is(r, 'abc', 'concat 3');
+ is(r, "abc", "concat 3");
r = (s1 + s2) + (s3 + s4);
- is(r, 'abcd', 'concat with parens');
+ is(r, "abcd", "concat with parens");
// String literals
- is(length("hello\n"), 6, 'length double quoted');
- is(length('hello\n'), 7, 'length single quoted');
-
- // String literal compile time concatenation mixing quote types
- r = "Hello\t" + '\tworld\n';
- is(r, "Hello\t\\tworld\\n", 'double + single');
- is(length(r), 15, 'length double + single');
- r = 'Hello\n' + "\tworld\n";
- is(r, "Hello\\n\tworld\n", 'single + double');
- is(length(r), 14, 'length single + double');
+ is(length("hello\n"), 6, "length double quoted");
// Non-ascii strings
r = "ñÑáéíóú";
- is(length(r), 7, 'non-ascii string have correct lenght');
- is(bytelength(r), 14, 'non-ascii string have correct byte lenght');
+ is(length(r), 7, "non-ascii string have correct lenght");
+ is(bytelength(r), 14, "non-ascii string have correct byte lenght");
}
// End
View
32 t/basic/01stringarray.t
@@ -9,29 +9,29 @@ function main()
plan(14);
string noinit [];
- ok(noinit instanceof 'ResizableStringArray', 'type of non initialized');
- is(elements(noinit), 0, 'size of non initialized');
+ ok(noinit instanceof "ResizableStringArray", "type of non initialized");
+ is(elements(noinit), 0, "size of non initialized");
- string a []= [ 'foo', 'bar' ];
- ok(a instanceof 'ResizableStringArray', 'type of initialized');
- is(elements(a), 2, 'size of initialized');
- is(a[0], 'foo', 'first value');
- is(a[1], 'bar', 'second value');
+ string a []= [ "foo", "bar" ];
+ ok(a instanceof "ResizableStringArray", "type of initialized");
+ is(elements(a), 2, "size of initialized");
+ is(a[0], "foo", "first value");
+ is(a[1], "bar", "second value");
string b [2];
- ok(b instanceof 'FixedStringArray', 'type of non initialized with size');
- is(elements(b), 2, 'size of non initialized with size');
+ ok(b instanceof "FixedStringArray", "type of non initialized with size");
+ is(elements(b), 2, "size of non initialized with size");
- string c [2] = [ 'foo', 'bar' ];
- ok(c instanceof 'FixedStringArray', 'type of initialized with size');
- is(elements(c), 2, 'size of initialized with size');
- is(c[0], 'foo', 'first value');
- is(c[1], 'bar', 'second value');
+ string c [2] = [ "foo", "bar" ];
+ ok(c instanceof "FixedStringArray", "type of initialized with size");
+ is(elements(c), 2, "size of initialized with size");
+ is(c[0], "foo", "first value");
+ is(c[1], "bar", "second value");
int size= 4;
string d[size];
- ok(c instanceof 'FixedStringArray', 'type of non initialized with size non constant');
- is(elements(d), size, 'size of non initialized with size non constant');
+ ok(c instanceof "FixedStringArray", "type of non initialized with size non constant");
+ is(elements(d), size, "size of non initialized with size non constant");
}
// End
View
24 t/basic/02arrayexpr.t
@@ -9,30 +9,30 @@ function main()
plan(11);
var a = [];
- is(elements(a), 0, 'empty');
+ is(elements(a), 0, "empty");
a = [7];
- is(elements(a), 1, 'one item');
- is(a[0], 7, 'integer value');
+ is(elements(a), 1, "one item");
+ is(a[0], 7, "integer value");
- a = ['hi'];
- is(a[0], 'hi', 'string value');
+ a = ["hi"];
+ is(a[0], "hi", "string value");
a = [42, "and all"];
- is(elements(a), 2, 'two mixed items');
- is(a[0], 42, 'first item');
- is(a[1], "and all", 'second item');
+ is(elements(a), 2, "two mixed items");
+ is(a[0], 42, "first item");
+ is(a[1], "and all", "second item");
int i = 69;
string s = "something";
a = [i, s];
- is(elements(a), 2, 'two mixed vars');
- is(a[0], 69, 'first item');
- is(a[1], "something", 'second item');
+ is(elements(a), 2, "two mixed vars");
+ is(a[0], 69, "first item");
+ is(a[1], "something", "second item");
a = [ foo ];
var f = a[0];
- is(f(), "this is foo", 'a function');
+ is(f(), "this is foo", "a function");
}
function foo()
View
12 t/basic/02bitwisetops.t
@@ -8,19 +8,19 @@ function main()
{
int a = 7;
int b = 3;
- is(a & b, 3, '7 & 3 : 3');
+ is(a & b, 3, "7 & 3 : 3");
a= 6;
- is(a & b, 2, '6 & 3 : 2');
+ is(a & b, 2, "6 & 3 : 2");
b= 1;
- is(a & b, 0, '6 & 1 : 0');
+ is(a & b, 0, "6 & 1 : 0");
a = 7;
b = 3;
- is(a | b, 7, '7 | 3 : 7');
+ is(a | b, 7, "7 | 3 : 7");
a= 17;
- is(a | b, 19, '17 | 3 : 19');
+ is(a | b, 19, "17 | 3 : 19");
b= 11;
- is(a | b, 27, '17 | 11 : 27');
+ is(a | b, 27, "17 | 11 : 27");
done_testing();
}
View
24 t/basic/02hashexpr.t
@@ -9,30 +9,30 @@ function main()
plan(11);
var h = {};
- is(elements(h), 0, 'empty');
+ is(elements(h), 0, "empty");
h = {"a" : 7};
- is(elements(h), 1, 'one item');
- is(h["a"], 7, 'integer value');
+ is(elements(h), 1, "one item");
+ is(h["a"], 7, "integer value");
- h = {"a" : 'hi'};
- is(h["a"], 'hi', 'string value');
+ h = {"a" : "hi"};
+ is(h["a"], "hi", "string value");
h = {"a" : 42, "b" : "and all"};
- is(elements(h), 2, 'two mixed items');
- is(h["a"], 42, 'int item');
- is(h["b"], "and all", 'string item');
+ is(elements(h), 2, "two mixed items");
+ is(h["a"], 42, "int item");
+ is(h["b"], "and all", "string item");
int i = 69;
string s = "something";
h = {"a" : i, "b" : s};
- is(elements(h), 2, 'two mixed vars');
- is(h["a"], 69, 'int item');
- is(h["b"], "something", 'string item');
+ is(elements(h), 2, "two mixed vars");
+ is(h["a"], 69, "int item");
+ is(h["b"], "something", "string item");
h = { "a" : foo };
var f = h["a"];
- is(f(), "this is foo", 'a function');
+ is(f(), "this is foo", "a function");
}
function foo()
View
16 t/basic/02predefuncs.t
@@ -12,19 +12,19 @@ function main [main]()
int a = 65;
// ord and chr
- is (chr(a), "A", 'chr with const argument');
- is (chr(65), "A", 'chr with non const argument');
- is (ord("A"), 65, 'ord with const argument');
- r = 'A';
- is (ord(r), 65, 'ord with non const argument');
+ is (chr(a), "A", "chr with const argument");
+ is (chr(65), "A", "chr with non const argument");
+ is (ord("A"), 65, "ord with const argument");
+ r = "A";
+ is (ord(r), 65, "ord with non const argument");
// Concatenate with chr.
r = "a" + chr(10);
- is(length(r), 2, 'concatenate literal and chr const - low value');
+ is(length(r), 2, "concatenate literal and chr const - low value");
r = "a" + chr(1000);
- is(length(r), 2, 'concatenate literal and chr const - high value');
+ is(length(r), 2, "concatenate literal and chr const - high value");
r = chr(10) + chr(1000);
- is(length(r), 2, 'concatenate two chr const');
+ is(length(r), 2, "concatenate two chr const");
// substr
is(substr("Winxed", 1, 2), "in", "substr literal 3 args");
View
6 t/basic/03functions.t
@@ -9,13 +9,13 @@ function main()
plan(3);
int i = retint();
- is(i, 42, 'return int to int');
+ is(i, 42, "return int to int");
var p = retint();
- is(p, 42, 'return int to var');
+ is(p, 42, "return int to var");
int j = retinteger();
- is (j, 69, 'return var to int');
+ is (j, 69, "return var to int");
}
function retint()
View
34 t/basic/04for.t
@@ -11,38 +11,38 @@ function main()
int check = 0;
for (;;) {
check = check + 1;
- is(check, 1, 'for (;;)');
+ is(check, 1, "for (;;)");
break;
}
string s;
int i;
for (i = 0; i < 5; i = i + 1)
- s = s + 'x';
- is(s, 'xxxxx', 'simple counting');
+ s = s + "x";
+ is(s, "xxxxx", "simple counting");
i = 0;
- s = '';
+ s = "";
for (; i < 5; i = i + 1)
- s = s + 'x';
- is(s, 'xxxxx', 'simple counting without initialization');
+ s = s + "x";
+ is(s, "xxxxx", "simple counting without initialization");
- s = '';
+ s = "";
for (i = 0; i < 0; i = i + 1)
- s = s + 'x';
- is(s, '', 'condition false at start');
+ s = s + "x";
+ is(s, "", "condition false at start");
i = 0;
- s = '';
+ s = "";
for (; i < 0; i = i + 1)
- s = s + 'x';
- is(s, '', 'condition false at start without initialization');
+ s = s + "x";
+ is(s, "", "condition false at start without initialization");
for (; i < 0;)
- s = s + 'x';
- is(s, '', 'condition false at start - condition only');
+ s = s + "x";
+ is(s, "", "condition false at start - condition only");
- for (s = ''; length(s) < 4;)
- s = s + 'x';
- is (s, 'xxxx', 'without increment');
+ for (s = ""; length(s) < 4;)
+ s = s + "x";
+ is (s, "xxxx", "without increment");
}
// End
View
4 t/basic/04switch.t
@@ -20,7 +20,7 @@ function main()
default:
check = 3;
}
- is(check, 2, 'simple expression-less switch');
+ is(check, 2, "simple expression-less switch");
i = 4;
check = 0;
@@ -34,7 +34,7 @@ function main()
default:
check = 3;
}
- is(check, 3, 'default case for switch');
+ is(check, 3, "default case for switch");
}
// End
View
36 t/basic/05new.t
@@ -11,7 +11,7 @@ function main()
var obj;
obj = new Foo;
- is(obj instanceof Foo, true, 'new without arguments without constructor');
+ is(obj instanceof Foo, true, "new without arguments without constructor");
int fail = 0;
try {
@@ -20,35 +20,35 @@ function main()
catch () {
fail = 1;
}
- is(fail, 1, 'new with empty argument list without constructor throws');
+ is(fail, 1, "new with empty argument list without constructor throws");
obj = new Bar;
- is(obj instanceof Bar, true, 'new without arguments with constructor');
- is_null(obj.b, 'constructor is not invoked');
+ is(obj instanceof Bar, true, "new without arguments with constructor");
+ is_null(obj.b, "constructor is not invoked");
obj = new Bar();
- ok(obj instanceof Bar, 'new with empty argument list with constructor');
- is(obj.b, 'Hi', 'constructor is invoked');
+ ok(obj instanceof Bar, "new with empty argument list with constructor");
+ is(obj.b, "Hi", "constructor is invoked");
obj = null;
obj = new Hill.Fool;
- ok(obj != null && obj.attr == null, 'new dotted without arguments');
+ ok(obj != null && obj.attr == null, "new dotted without arguments");
obj = new Hill.Fool();
- is(obj.attr, 42, 'new dotted with empty argument list');
+ is(obj.attr, 42, "new dotted with empty argument list");
- obj = new 'String';
- ok(obj instanceof 'String', 'new with string literal');
+ obj = new "String";
+ ok(obj instanceof "String", "new with string literal");
- obj = new ['Integer'];
- ok(obj instanceof 'Integer', 'new with key');
+ obj = new ["Integer"];
+ ok(obj instanceof "Integer", "new with key");
- obj = new ['Integer'](42);
- is(obj, 42, 'new with key - int argument');
+ obj = new ["Integer"](42);
+ is(obj, 42, "new with key - int argument");
- obj = new ['Exception']( { "severity": 1, "message": "foobar" } );
- ok((obj instanceof 'Exception') && obj["severity"] == 1 && obj["message"] == "foobar",
- 'new with key - var argument');
+ obj = new ["Exception"]( { "severity": 1, "message": "foobar" } );
+ ok((obj instanceof "Exception") && obj["severity"] == 1 && obj["message"] == "foobar",
+ "new with key - var argument");
}
class Foo
@@ -60,7 +60,7 @@ class Bar
var b;
function Bar()
{
- self.b = 'Hi';
+ self.b = "Hi";
}
}
View
74 t/harness
@@ -2,7 +2,7 @@
// harness for winxed tests
// TAP parsing adapted from nqp in plumage harness
-$load 'Getopt/Obj.pbc';
+$load "Getopt/Obj.pbc";
function debugmsg(string s)
{
@@ -17,14 +17,14 @@ function run_test(string filename, int debug, string stage)
// If specified, assume we are in the build tree and use the
// non installed driver to select stage.
string s= stage == "" ?
- 'winxed' :
- 'parrot winxedrun.pbc --stage=' + stage;
+ "winxed" :
+ "parrot winxedrun.pbc --stage=" + stage;
if (debug)
s = s + " --debug";
- s = s + ' ' + filename;
+ s = s + " " + filename;
debugmsg(s);
- var fh= open(s, 'rp');
+ var fh= open(s, "rp");
fh.encoding("utf8");
string test_output= fh.readall();
fh.close();
@@ -51,7 +51,7 @@ function run_test_list(var args, int verbose, string stage, int debug)
int l= max_length(args) + 2;
for (string filename in args) {
- print(filename, '.' * (l - length(filename)));
+ print(filename, "." * (l - length(filename)));
total_files = total_files + 1;
int passed= 0;
int failed= 0;
@@ -62,39 +62,39 @@ function run_test_list(var args, int verbose, string stage, int debug)
var plan_part0;
var plan_part1;
{
- var plan_parts= split('..', output[0]);
+ var plan_parts= split("..", output[0]);
plan_part0 = plan_parts[0];
plan_part1 = plan_parts[1];
}
if (plan_part0.is_integer(plan_part0)) {
num_tests = plan_part1;
output.shift();
if (verbose)
- say(1 , '..', num_tests);
+ say(1 , "..", num_tests);
}
for (string line in output) {
debugmsg(line);
- if (line != '') {
+ if (line != "") {
if (verbose)
say(line);
if (num_tests < 0) {
- var plan_parts= split('..', line);
+ var plan_parts= split("..", line);
var p0 = plan_parts[0];
if (p0.is_integer(p0)) {
plan_part0 = plan_parts[0];
plan_part1 = plan_parts[1];
num_tests = plan_part1;
if (verbose)
- say(1 , '..', num_tests);
+ say(1 , "..", num_tests);
}
}
- var line_parts = split('ok ', line);
+ var line_parts = split("ok ", line);
int test_number= line_parts[1];
debugmsg(test_number);
string part= line_parts[0];
debugmsg(part);
- if (part == 'not ') {
+ if (part == "not ") {
failed = failed + 1;
curr_test = curr_test + 1;
}
@@ -105,38 +105,38 @@ function run_test_list(var args, int verbose, string stage, int debug)
}
}
if (failed)
- say('failed ', failed, '/', num_tests, ' tests');
+ say("failed ", failed, "/", num_tests, " tests");
else if (plan_part0 != 1 || (num_tests < 0)) {
- say('INVALID PLAN: ', plan_part0, '..', plan_part1);
+ say("INVALID PLAN: ", plan_part0, "..", plan_part1);
failed_files = failed_files + 1;
}
else
- say('passed ', curr_test, ' tests');
+ say("passed ", curr_test, " tests");
total_passed= total_passed + passed;
total_failed= total_failed + failed;
if (num_tests != curr_test) {
- say('Planned to run ', num_tests, ' tests but ran ', curr_test, ' tests');
- say('FAILED');
+ say("Planned to run ", num_tests, " tests but ran ", curr_test, " tests");
+ say("FAILED");
}
}
if (total_failed) {
int total= total_passed + total_failed;
- say('FAILED ', total_failed, '/', total);
+ say("FAILED ", total_failed, "/", total);
}
else if (failed_files)
- say('FAILED ', failed_files, ' files, PASSED ', total_passed, ' tests');
+ say("FAILED ", failed_files, " files, PASSED ", total_passed, " tests");
else
- say('PASSED ', total_passed, ' tests in ', total_files, ' files');
+ say("PASSED ", total_passed, " tests in ", total_files, " files");
}
// Use the OS pmc for file operations.
function getOS()
{
var os;
try {
- loadlib('os');
- os = new ['OS'];
+ loadlib("os");
+ os = new ["OS"];
}
catch() { }
return os;
@@ -145,7 +145,7 @@ function getOS()
function add_file(var result, string path)
{
// Add a file to result list only if it has a .t extension.
- if (length(path) > 2 && substr(path, -2) == '.t')
+ if (length(path) > 2 && substr(path, -2) == ".t")
result.push(path);
}
@@ -157,12 +157,12 @@ function build_from_dir(var result, string path, int recursive)
var dirpaths = [];
var os = getOS();
int l = length(path);
- if (substr(path, l - 1, 1) == '/')
+ if (substr(path, l - 1, 1) == "/")
path = substr(path, 0, l - 1);
var dir = os.readdir(path);
for (string dirent in dir)
- if ((dirent != '.') && (dirent != '..')) {
- string newpath = (path == '.') ? dirent : path + '/' + dirent;
+ if ((dirent != ".") && (dirent != "..")) {
+ string newpath = (path == ".") ? dirent : path + "/" + dirent;
var st= os.stat(newpath);
int mode = st[2];
if ((mode & 16384) != 0)
@@ -198,29 +198,29 @@ function build_file_list(var result, var args, int recursive)
function main(var argv)
{
- var getopts = new ['Getopt','Obj'];
+ var getopts = new ["Getopt","Obj"];
getopts.notOptStop(1);
- getopts.push_string('v');
- getopts.push_string('r');
- getopts.push_string('stage=s');
- getopts.push_string('debug');
+ getopts.push_string("v");
+ getopts.push_string("r");
+ getopts.push_string("stage=s");
+ getopts.push_string("debug");
argv.shift();
var opts = getopts.get_options(argv);
- var optverbose = opts['v'];
- var optrecursive = opts['r'];
- var optdebug = opts['debug'];
+ var optverbose = opts["v"];
+ var optrecursive = opts["r"];
+ var optdebug = opts["debug"];
int verbose = optverbose == null ? 0 : int(optverbose);
int recursive = optrecursive == null ? 0 : int(optrecursive);
int debug = optdebug != null;
- var opt_stage = opts['stage'];
+ var opt_stage = opts["stage"];
string stage = "";
if (opt_stage != null)
stage = opt_stage;
int argc= argv;
if (argc == 0)
- argv.push('.');
+ argv.push(".");
string args[];
build_file_list(args, argv, recursive);
View
20 t/instanceof.t
@@ -2,7 +2,7 @@
// Mininal tests of instanceof operator
-class MyArray : 'ResizablePMCArray'
+class MyArray : "ResizablePMCArray"
{
}
@@ -18,17 +18,17 @@ function main [main] ()
plan(4);
- var a = new 'ResizableBooleanArray';
- int check= a instanceof 'ResizableBooleanArray';
- is (check, 1, 'is own type');
- check= a instanceof 'FixedPMCArray';
- is (check, 0, 'is not a different type');
+ var a = new "ResizableBooleanArray";
+ int check= a instanceof "ResizableBooleanArray";
+ is (check, 1, "is own type");
+ check= a instanceof "FixedPMCArray";
+ is (check, 0, "is not a different type");
var b = new MyArray;
- check= b instanceof 'ResizablePMCArray';
- is (check, 1, 'is a parent');
+ check= b instanceof "ResizablePMCArray";
+ is (check, 1, "is a parent");
var c = new MyArray;
- check= c instanceof 'ResizablePMCArray';
- is (check, 1, 'is a grandparent');
+ check= c instanceof "ResizablePMCArray";
+ is (check, 1, "is a grandparent");
}
// End
View
13 t/medium/01string.t
@@ -6,10 +6,21 @@ using extern Test.More plan, is;
function main()
{
- plan(3);
+ plan(8);
string r;
+ // String literals
+ is(length('hello\n'), 7, "length single quoted");
+
+ // String literal compile time concatenation mixing quote types
+ r = "Hello\t" + '\tworld\n';
+ is(r, "Hello\t\\tworld\\n", "double + single");
+ is(length(r), 15, "length double + single");
+ r = 'Hello\n' + "\tworld\n";
+ is(r, "Hello\\n\tworld\n", "single + double");
+ is(length(r), 14, "length single + double");
+
// Non-ascii escape sequences
r = "\xf1";
is(length(r), 1, "non-ascii hex escape have correct length");
View
6 t/parent.t
@@ -23,9 +23,9 @@ function main()
plan(3);
var bar = new Bar;
- is(bar.f1(), 'Bar.f1', 'overrides parent function');
- is(bar.f2(), 'Foo.f2', 'uses parent function');
- is(bar.f3(), 'Bar.f1', 'parent function uses child override with self');
+ is(bar.f1(), "Bar.f1", "overrides parent function");
+ is(bar.f2(), "Foo.f2", "uses parent function");
+ is(bar.f3(), "Bar.f1", "parent function uses child override with self");
}
// End
View
2 t/self.t
@@ -25,7 +25,7 @@ function main()
var f= new Foo;
f.init(42);
- is(f.get(), 42, 'set and get via self');
+ is(f.get(), 42, "set and get via self");
}
// End
View
12 t/test.t
@@ -9,19 +9,19 @@ function int_cmp()
using Test.More.isnt;
int i= 2 - 1;
- is(i, 1, 'int equal');
+ is(i, 1, "int equal");
i = 2 + 3;
- isnt(i, 1, 'int not equal');
+ isnt(i, 1, "int not equal");
}
function string_cmp()
{
using Test.More.is;
using Test.More.isnt;
- string s= 'Hi';
- is(s, 'Hi', 'string equal');
- isnt(s, 'Ho', 'string not equal');
+ string s= "Hi";
+ is(s, "Hi", "string equal");
+ isnt(s, "Ho", "string not equal");
}
function foo()
@@ -34,7 +34,7 @@ function func_calls()
using Test.More.is;
string s= foo();
- is(s, 'bar', 'function returning string');
+ is(s, "bar", "function returning string");
}
function main [main] ()
View
4 t/throw.t
@@ -2,7 +2,7 @@
function aux()
{
- throw new 'Exception'({ 'message': 'something bad' });
+ throw new "Exception"({ "message": "something bad" });
}
function main()
@@ -15,6 +15,6 @@ function main()
try aux();
catch (e)
{
- is(e['message'], 'something bad', 'get Exception message');
+ is(e["message"], "something bad", "get Exception message");
}
}
View
12 t/var.t
@@ -8,11 +8,11 @@ function main()
plan(4);
var a = 1;
- is(a, 1, 'initialize from int');
- var b = 'Hi';
- is(b, 'Hi', 'initialize from string');
+ is(a, 1, "initialize from int");
+ var b = "Hi";
+ is(b, "Hi", "initialize from string");
var c; c = 1;
- is(c, 1, 'assign from int');
- var d; d = 'Hi';
- is(d, 'Hi', 'assign from string');
+ is(c, 1, "assign from int");
+ var d; d = "Hi";
+ is(d, "Hi", "assign from string");
}
View
4 t/vtable.t
@@ -6,7 +6,7 @@ class Foo
{
function get_string [vtable] ()
{
- return 'Hello, Foo';
+ return "Hello, Foo";
}
}
@@ -19,7 +19,7 @@ function main()
plan(1);
var f= new Foo;
string s= f;
- is (s, 'Hello, Foo', 'vtable get_string');
+ is (s, "Hello, Foo", "vtable get_string");
}
// End
View
45 token.cpp
@@ -1,5 +1,5 @@
// token.cpp
-// Revision 24-nov-2011
+// Revision 24-may-2012
#include "token.h"
#include "errors.h"
@@ -9,8 +9,6 @@
#include <string.h>
#include <stdlib.h>
-static std::string unsinglequote (const std::string &s);
-
//**********************************************************************
static std::string tostring(int n)
@@ -92,8 +90,6 @@ std::string Token::identifier() const
std::string Token::pirliteralstring() const
{
switch (ttype) {
- case TokenTSingleQuoted:
- return unsinglequote(s);
case TokenTQuoted:
return unquote(s);
default:
@@ -106,8 +102,6 @@ std::string Token::describe() const
switch (ttype) {
case TokenTEOF:
return "*End of file*";
- case TokenTSingleQuoted:
- return "'" + s + "'";
case TokenTQuoted:
return "\"" + unquote(s) + "\"";
case TokenTOperator:
@@ -131,11 +125,8 @@ bool Token::isidentifier() const
bool Token::isinteger() const
{ return ttype == TokenTInteger; }
-bool Token::issinglequoted() const
-{ return ttype == TokenTSingleQuoted; }
-
bool Token::isliteralstring() const
-{ return ttype == TokenTSingleQuoted || ttype == TokenTQuoted; }
+{ return ttype == TokenTQuoted; }
bool Token::isop(const std::string &name) const
{
@@ -223,21 +214,6 @@ std::string unquote (const std::string &s)
return (nonascii ? "utf8:\"" : "\"") + r + "\"";
}
-static std::string unsinglequote (const std::string &s)
-{
- bool nonascii= false;
- for (size_t i= 0; i < s.size(); ++i)
- {
- unsigned char c= s[i];
- if (c > 127)
- nonascii= true;
- }
- if (nonascii)
- return unquote(s);
- else
- return '\'' + s + '\'';
-}
-
//**********************************************************************
Tokenizer::Tokenizer (std::istream &is_a, const char *filename) :
@@ -328,21 +304,6 @@ Token Tokenizer::getquoted()
return Token(TokenTQuoted, s, linenum, name);
}
-Token Tokenizer::getsinglequoted()
-{
- std::string s;
- unsigned int linenum = ln;
- char c;
- while ((c= getchar()) && is && c != '\'' && c != '\n')
- s+= c;
- if ((!is) || c != '\'')
- {
- throw SyntaxError("Unterminated string",
- Token(TokenTSingleQuoted, s, linenum, name));
- }
- return Token(TokenTSingleQuoted, s, linenum, name);
-}
-
Token Tokenizer::getheredoc()
{
unsigned int linenum = ln;
@@ -510,8 +471,6 @@ Token Tokenizer::getany ()
ungetchar(c);
}
break;
- case '\'':
- return getsinglequoted ();
case '"':
return getquoted ();
case '0':
View
4 token.h
@@ -2,7 +2,7 @@
#define INCLUDE_TOKEN_H
// token.h
-// Revision 10-jul-2010
+// Revision 24-may-2012
#include <string>
#include <istream>
@@ -14,7 +14,6 @@ enum TokenType
TokenTComment,
TokenTWhiteSpace,
TokenTInteger,
- TokenTSingleQuoted,
TokenTQuoted,
TokenTIdentifier,
TokenTOperator,
@@ -68,7 +67,6 @@ class Tokenizer
char getchar();
void ungetchar(char c);
Token getquoted();
- Token getsinglequoted();
Token getheredoc();
Token getany();
View
172 winxed.winxed
@@ -4,7 +4,7 @@
// Parses command line options, calls the compiler backend
// and eventually runs the generated program.
-$load 'Getopt/Obj.pbc';
+$load "Getopt/Obj.pbc";
// This driver must be compilable with stage 0, can't use $incldue_const
// here, so harcode the values from iglobals.pasm and libpaths.pasm
@@ -16,7 +16,7 @@ function extname(string filename, string ext)
// Strip a possible .winxed extension from filename,
// add ext, and return the result.
int l = length(filename);
- return (l > 7 && substr(filename, -7) == '.winxed') ?
+ return (l > 7 && substr(filename, -7) == ".winxed") ?
substr(filename, 0, l - 7) + ext :
filename + ext;
}
@@ -26,14 +26,14 @@ function getOS()
{
var os;
try {
- loadlib('os');
- os = new ['OS'];
+ loadlib("os");
+ os = new ["OS"];
}
catch() { }
return os;
}
-class WinxedDriverOptions : ['Getopt', 'Obj']
+class WinxedDriverOptions : ["Getopt", "Obj"]
{
var name;
var options;
@@ -42,19 +42,19 @@ class WinxedDriverOptions : ['Getopt', 'Obj']
function WinxedDriverOptions(argv, int unused)
{
var options = [
- [ 'stage=s', 'Compiler stage to use' ],
- [ 'c', 'Compile only. Same as --target=pir' ],
- [ 'e=s', 'Evaluate' ],
- [ 'o=s', 'Object name' ],
- [ 'L=s', 'Add to parrot library search path' ],
- [ 'I=s', 'Add to parrot include search path' ],
- [ 'X=s', 'Add to parrot dynext search path' ],
- [ 'debug', 'Set debug mode' ],
- [ 'noan', 'No code annotations' ],
- [ 'nowarn', 'No warnings' ],
- [ 'target=s', 'Set target type: pir, pbc or run. Default is run.' ],
- [ 'help', 'Show this help' ],
- [ 'version', 'Show version and exit' ]
+ [ "stage=s", "Compiler stage to use" ],
+ [ "c", "Compile only. Same as --target=pir" ],
+ [ "e=s", "Evaluate" ],
+ [ "o=s", "Object name" ],
+ [ "L=s", "Add to parrot library search path" ],
+ [ "I=s", "Add to parrot include search path" ],
+ [ "X=s", "Add to parrot dynext search path" ],
+ [ "debug", "Set debug mode" ],
+ [ "noan", "No code annotations" ],
+ [ "nowarn", "No warnings" ],
+ [ "target=s", "Set target type: pir, pbc or run. Default is run." ],
+ [ "help", "Show this help" ],
+ [ "version", "Show version and exit" ]
];
self.options = options;
for (var o in options)
@@ -77,8 +77,8 @@ class WinxedDriverOptions : ['Getopt', 'Obj']
}
function showhelp()
{
- say('Usage: ', self.name, ' [options] [program] [args]');
- say(' Available options:');
+ say("Usage: ", self.name, " [options] [program] [args]");
+ say(" Available options:");
int l= 0;
int i;
var o;
@@ -88,12 +88,12 @@ class WinxedDriverOptions : ['Getopt', 'Obj']
}
for (o in self.options) {
string s= o[0];
- if (length(s) > 1 && substr(s, 1, 1) != '=')
- s= '--' + s;
+ if (length(s) > 1 && substr(s, 1, 1) != "=")
+ s= "--" + s;
else
- s= '-' + s;
+ s= "-" + s;
i= l - length(s);
- say(' ', s, ' ' * i, '-> ', o[1]);
+ say(" ", s, " " * i, "-> ", o[1]);
}
}
}
@@ -106,33 +106,33 @@ function driver_main(argv)
var options = new WinxedDriverOptions(argv, 0);
- int help = options.getbool('help');
- int version = options.getbool('version');
- string opt_stage = options.getstring('stage');
- int compileonly = options.getbool('c');
- int debug = options.getbool('debug');
- int noan = options.getbool('noan');
- int nowarn = options.getbool('nowarn');
- string eval = options.getstring('e');
- string libs = options.getstring('L');
- string incs = options.getstring('I');
- string dyns = options.getstring('X');
- string obj = options.getstring('o', '');
- string target = options.getstring('target');
+ int help = options.getbool("help");
+ int version = options.getbool("version");
+ string opt_stage = options.getstring("stage");
+ int compileonly = options.getbool("c");
+ int debug = options.getbool("debug");
+ int noan = options.getbool("noan");
+ int nowarn = options.getbool("nowarn");
+ string eval = options.getstring("e");
+ string libs = options.getstring("L");
+ string incs = options.getstring("I");
+ string dyns = options.getstring("X");
+ string obj = options.getstring("o", "");
+ string target = options.getstring("target");
if (help) {
options.showhelp();
return;
}
- var env = new 'Env';
+ var env = new "Env";
// Path for stage pbc files
- string winxedpath = env['WINXED_PATH'];
+ string winxedpath = env["WINXED_PATH"];
int stage = DEFAULT_STAGE;
if (opt_stage == null) {
- string envstage = env['WINXED_STAGE'];
- if (envstage != '')
+ string envstage = env["WINXED_STAGE"];
+ if (envstage != "")
opt_stage = envstage;
}
if (opt_stage != null) {
@@ -157,20 +157,20 @@ function driver_main(argv)
if (target != null) {
switch (target) {
- case 'pir':
+ case "pir":
targettype = TargetPir;
break;
- case 'pbc':
+ case "pbc":
targettype = TargetPbc;
break;
- case 'run':
+ case "run":
targettype = TargetRun;
break;
- case 'include':
+ case "include":
targettype = TargetConst;
break;
default:
- throw 'Invalid target: ' + target;
+ throw "Invalid target: " + target;
}
}
if (compileonly) {
@@ -193,13 +193,13 @@ function driver_main(argv)
}
string pirfile;
- if (obj != '' && targettype == TargetPir || targettype == TargetConst)
+ if (obj != "" && targettype == TargetPir || targettype == TargetConst)
pirfile = obj;
else {
if (eval != null)
- pirfile = '__eval__.pir';
+ pirfile = "__eval__.pir";
else
- pirfile = extname(srcfile, '.pir');
+ pirfile = extname(srcfile, ".pir");
}
var os = getOS();
@@ -209,22 +209,22 @@ function driver_main(argv)
string winxedbin;
switch (stage) {
case 0:
- winxedbin = 'winxedst0';
+ winxedbin = "winxedst0";
break;
case 1:
- winxedbin = 'winxedst1';
+ winxedbin = "winxedst1";
break;
case 2:
- winxedbin = 'winxedst2';
+ winxedbin = "winxedst2";
break;
case 3:
- winxedbin = 'winxedst3';
+ winxedbin = "winxedst3";
break;
case CUSTOM_STAGE:
winxedbin = opt_stage;
break;
default:
- throw 'Invalid stage ' + stage + '. Must be 0, 1, 2 or 3 .';
+ throw "Invalid stage " + stage + ". Must be 0, 1, 2 or 3 .";
}
int retval = 0;
@@ -240,20 +240,20 @@ function driver_main(argv)
}
try {
- load_bytecode(winxedbin + '.pbc');
+ load_bytecode(winxedbin + ".pbc");
} catch () { }
- var compiler = compreg('winxed');
+ var compiler = compreg("winxed");
if (compiler == null) {
- if (winxedpath != null && winxedpath != '') {
- winxedbin = winxedpath + '/' + winxedbin;
+ if (winxedpath != null && winxedpath != "") {
+ winxedbin = winxedpath + "/" + winxedbin;
try {
- load_bytecode(winxedbin + '.pbc');
+ load_bytecode(winxedbin + ".pbc");
}
catch (e) {
if (__DEBUG__)
cry("Cannot load ", winxedbin, ": ", e["message"]);
}
- compiler = compreg('winxed');
+ compiler = compreg("winxed");
}
if (compiler == null)
throw "Cannot load stage " + winxedbin;
@@ -265,7 +265,7 @@ function driver_main(argv)
say(ver);
exit(0);
}
- string ctarget = targettype == TargetConst ? 'include' : 'pir';
+ string ctarget = targettype == TargetConst ? "include" : "pir";
var opts = {
"target": ctarget,
"debug": debug,
@@ -276,27 +276,27 @@ function driver_main(argv)
if (eval == null) {
var output;
var file;
- if (pirfile == '-' &&
+ if (pirfile == "-" &&
(targettype == TargetPir || targettype == TargetConst))
output = getstdout();
else {
- file = open(pirfile, 'w');
+ file = open(pirfile, "w");
output = file;
}
- opts['output'] = output;
+ opts["output"] = output;
compiler.compile_from_file(srcfile, opts:[named,flat]);
if (file != null)
file.close();
}
else {
- eval = 'function main[main](argv){' + eval + ';}';
+ eval = "function main[main](argv){" + eval + ";}";
pircode = compiler.compile(eval, opts:[named,flat]);
- if (pirfile == '-' &&
+ if (pirfile == "-" &&
(targettype == TargetPir || targettype == TargetConst))
print(pircode);
else {
- var file = open(pirfile, 'w');
+ var file = open(pirfile, "w");
file.print(pircode);
file.close();
}
@@ -314,8 +314,8 @@ function driver_main(argv)
// directory and has no extension, use it.
// If not, assume it's in the PATH or we are on Windows.
var check = null;
- if (winxedpath != null && winxedpath != '' &&os != null) {
- string checkbin = winxedpath + '/' + winxedbin;
+ if (winxedpath != null && winxedpath != "" &&os != null) {
+ string checkbin = winxedpath + "/" + winxedbin;
check = os.stat(checkbin);
if (check == null) {
checkbin = winxedpath + "\\" + winxedbin + ".exe";
@@ -328,25 +328,25 @@ function driver_main(argv)
if (os != null)
check = os.stat(winxedbin);
if (check != null)
- winxedbin = './' + winxedbin;
+ winxedbin = "./" + winxedbin;
}
cmd.push(winxedbin);
}
if (targettype == TargetConst)
- throw 'target include unavailable in stage 0';
+ throw "target include unavailable in stage 0";
if (debug)
- cmd.push('--debug');
+ cmd.push("--debug");
if (noan)
- cmd.push('--noan');
+ cmd.push("--noan");
if (nowarn && stage != 0)
- cmd.push('--nowarn');
+ cmd.push("--nowarn");
if (eval != null) {
- cmd.push('-e');
+ cmd.push("-e");
cmd.push(eval);
}
- cmd.push('-o');
+ cmd.push("-o");
cmd.push(pirfile);
if (eval == null)
cmd.push(srcfile);
@@ -357,21 +357,21 @@ function driver_main(argv)
if (retval)
exit(retval);
- string runit[] = [ 'parrot' ];
+ string runit[] = [ "parrot" ];
switch (targettype) {
case TargetRun:
// Execute result
if (libs != null) {
- runit.push('-L');
+ runit.push("-L");
runit.push(libs);
}
if (incs != null) {
- runit.push('-I');
+ runit.push("-I");
runit.push(incs);
}
if (dyns != null) {
- runit.push('-X');
+ runit.push("-X");
runit.push(dyns);
}
runit.push(pirfile);
@@ -384,17 +384,17 @@ function driver_main(argv)
}
catch (e)
{
- cry('WARNING: cannot delete temporary PIR file: ', e['message']);
+ cry("WARNING: cannot delete temporary PIR file: ", e["message"]);
}
break;
case TargetPbc:
// Call parrot to ceate the pbc
string objfile;
- if (obj != '')
+ if (obj != "")
objfile = obj;
else
- objfile = extname(srcfile, '.pbc');
- runit.push('-o');
+ objfile = extname(srcfile, ".pbc");
+ runit.push("-o");
runit.push(objfile);
runit.push(pirfile);
retval = spawnw(runit);
@@ -404,7 +404,7 @@ function driver_main(argv)
}
catch (e)
{
- cry('WARNING: cannot delete temporary PIR file: ', e['message']);
+ cry("WARNING: cannot delete temporary PIR file: ", e["message"]);
}
break;
default:
@@ -423,7 +423,7 @@ function main [main] (argv)
catch (e) {
var payload = e["payload"];
if (payload != null)
- cry(payload.filename, ':', payload.line, ': ', payload.message);
+ cry(payload.filename, ":", payload.line, ": ", payload.message);
else
cry(e["message"]);
r = 1;
View
2 winxedst0.cpp
@@ -6438,7 +6438,7 @@ class RootNamespaceBlock : public NamespaceBlockBase
else if (name == "__STAGE__") {
// This is stage 0
return ConstantValue(REGstring,
- Token(TokenTSingleQuoted, "0", 0, "__predefconst__"));
+ Token(TokenTQuoted, "0", 0, "__predefconst__"));
}
else if (name == "__DEBUG__") {
return ConstantValue(REGint,
View
1,602 winxedst1.winxed
801 additions, 801 deletions not shown because the diff is too large. Please use a local Git client to view these changes.

0 comments on commit 01b5c40

Please sign in to comment.