From ff3db92711bd250f6b20dc3c25f2453ecc34289f Mon Sep 17 00:00:00 2001 From: "rginda%netscape.com" Date: Wed, 18 Oct 2000 22:01:17 +0000 Subject: [PATCH] making argument name optional in argumetlists --- js/js2/ica_test.cpp | 16 ++++++++-------- js/js2/icodeasm.cpp | 28 ++++++++++++++++------------ js2/src/ica_test.cpp | 16 ++++++++-------- js2/src/icodeasm.cpp | 28 ++++++++++++++++------------ 4 files changed, 48 insertions(+), 40 deletions(-) diff --git a/js/js2/ica_test.cpp b/js/js2/ica_test.cpp index 0c7a48f4073..2f6e2cd002d 100644 --- a/js/js2/ica_test.cpp +++ b/js/js2/ica_test.cpp @@ -144,14 +144,14 @@ main (int , char **) //testUInt32 (icp, "12123687213612873621873438754387934657834", 0); string src = -"some_label:\n\ -LOAD_STRING R1, 'hello' ;test comment\n\ -CAST R2, R1, 'any';another test comment\n\ -SAVE_NAME 'x', R2\n\ -LOAD_NAME R1, 'x'\n\ -LOAD_NAME R2, 'print'\n\ -CALL R3, R2, , ('foo':R1)\n\ -RETURN R3"; +"some_label:\n" +"LOAD_STRING R1, 'hello' ;test comment\n" +"CAST R2, R1, 'any';another test comment\n" +"SAVE_NAME 'x', R2\n" +"LOAD_NAME R1, 'x'\n" +"LOAD_NAME R2, 'print'\n" +"CALL R3, R2, , (R1, R2)\n" +"RETURN R3"; testParse (icp, src); diff --git a/js/js2/icodeasm.cpp b/js/js2/icodeasm.cpp index 154a019a3ff..b5ba9d2a657 100644 --- a/js/js2/icodeasm.cpp +++ b/js/js2/icodeasm.cpp @@ -448,7 +448,7 @@ namespace ICodeASM { ICodeParser::ParseArgumentListOperand (iter begin, iter end, VM::ArgumentList **rval) { - /* parse argument list on the format "('argname': register[, ...])" */ + /* parse argument list on the format "(['argname': ]register[, ...])" */ TokenLocation tl = SeekTokenStart (begin, end); VM::ArgumentList *al = new VM::ArgumentList(); @@ -456,18 +456,22 @@ namespace ICodeASM { throw new ICodeParseException ("Expected Argument List"); tl = SeekTokenStart (tl.begin + 1, end); - while (tl.estimate == teString) { - /* look for the argname in quotes */ - string *argName; - begin = ParseString (tl.begin, end, &argName); + while (tl.estimate == teString || tl.estimate == teAlpha) { + string *argName = 0; - /* look for the : */ - tl = SeekTokenStart (begin, end); - if (tl.estimate != teColon) - throw new ICodeParseException ("Expected colon"); + if (tl.estimate == teString) { + /* look for the argname in quotes */ + begin = ParseString (tl.begin, end, &argName); + + /* look for the : */ + tl = SeekTokenStart (begin, end); + if (tl.estimate != teColon) + throw new ICodeParseException ("Expected colon"); + + /* and now the register */ + tl = SeekTokenStart (tl.begin + 1, end); + } - /* and now the register */ - tl = SeekTokenStart (tl.begin + 1, end); if (tl.estimate != teAlpha) throw new ICodeParseException ("Expected Register value"); @@ -486,7 +490,7 @@ namespace ICodeASM { /* if the next token is a comma, * seek to the next one and go again */ if (tl.estimate == teComma) { - tl = SeekTokenStart (tl.begin, end); + tl = SeekTokenStart (tl.begin + 1, end); } } diff --git a/js2/src/ica_test.cpp b/js2/src/ica_test.cpp index 0c7a48f4073..2f6e2cd002d 100644 --- a/js2/src/ica_test.cpp +++ b/js2/src/ica_test.cpp @@ -144,14 +144,14 @@ main (int , char **) //testUInt32 (icp, "12123687213612873621873438754387934657834", 0); string src = -"some_label:\n\ -LOAD_STRING R1, 'hello' ;test comment\n\ -CAST R2, R1, 'any';another test comment\n\ -SAVE_NAME 'x', R2\n\ -LOAD_NAME R1, 'x'\n\ -LOAD_NAME R2, 'print'\n\ -CALL R3, R2, , ('foo':R1)\n\ -RETURN R3"; +"some_label:\n" +"LOAD_STRING R1, 'hello' ;test comment\n" +"CAST R2, R1, 'any';another test comment\n" +"SAVE_NAME 'x', R2\n" +"LOAD_NAME R1, 'x'\n" +"LOAD_NAME R2, 'print'\n" +"CALL R3, R2, , (R1, R2)\n" +"RETURN R3"; testParse (icp, src); diff --git a/js2/src/icodeasm.cpp b/js2/src/icodeasm.cpp index 154a019a3ff..b5ba9d2a657 100644 --- a/js2/src/icodeasm.cpp +++ b/js2/src/icodeasm.cpp @@ -448,7 +448,7 @@ namespace ICodeASM { ICodeParser::ParseArgumentListOperand (iter begin, iter end, VM::ArgumentList **rval) { - /* parse argument list on the format "('argname': register[, ...])" */ + /* parse argument list on the format "(['argname': ]register[, ...])" */ TokenLocation tl = SeekTokenStart (begin, end); VM::ArgumentList *al = new VM::ArgumentList(); @@ -456,18 +456,22 @@ namespace ICodeASM { throw new ICodeParseException ("Expected Argument List"); tl = SeekTokenStart (tl.begin + 1, end); - while (tl.estimate == teString) { - /* look for the argname in quotes */ - string *argName; - begin = ParseString (tl.begin, end, &argName); + while (tl.estimate == teString || tl.estimate == teAlpha) { + string *argName = 0; - /* look for the : */ - tl = SeekTokenStart (begin, end); - if (tl.estimate != teColon) - throw new ICodeParseException ("Expected colon"); + if (tl.estimate == teString) { + /* look for the argname in quotes */ + begin = ParseString (tl.begin, end, &argName); + + /* look for the : */ + tl = SeekTokenStart (begin, end); + if (tl.estimate != teColon) + throw new ICodeParseException ("Expected colon"); + + /* and now the register */ + tl = SeekTokenStart (tl.begin + 1, end); + } - /* and now the register */ - tl = SeekTokenStart (tl.begin + 1, end); if (tl.estimate != teAlpha) throw new ICodeParseException ("Expected Register value"); @@ -486,7 +490,7 @@ namespace ICodeASM { /* if the next token is a comma, * seek to the next one and go again */ if (tl.estimate == teComma) { - tl = SeekTokenStart (tl.begin, end); + tl = SeekTokenStart (tl.begin + 1, end); } }