зеркало из https://github.com/mozilla/pjs.git
making argument name optional in argumetlists
This commit is contained in:
Родитель
1cb3536755
Коммит
ff3db92711
|
@ -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, <NaR>, ('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, <NaR>, (R1, R2)\n"
|
||||
"RETURN R3";
|
||||
|
||||
testParse (icp, src);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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, <NaR>, ('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, <NaR>, (R1, R2)\n"
|
||||
"RETURN R3";
|
||||
|
||||
testParse (icp, src);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче