enhanced the array literal reader to allow a comma if used after the first element
This commit is contained in:
parent
6a80f08bae
commit
3874483b23
@ -13,9 +13,15 @@ class FileAccessor(InputOutputStud) from "io.file"
|
|||||||
{
|
{
|
||||||
//O_RDONLY := 0,
|
//O_RDONLY := 0,
|
||||||
//O_WRONLY := 1
|
//O_WRONLY := 1
|
||||||
|
O_CLOEXEC from "O_CLOEXEC",
|
||||||
|
O_CREAT from "O_CREAT",
|
||||||
|
O_EXCL from "O_EXCL",
|
||||||
|
O_NOFOLLOW from "O_NOFOLLOW",
|
||||||
|
O_NONBLOCK from "O_NONBLOCK",
|
||||||
O_RDONLY from "O_RDONLY",
|
O_RDONLY from "O_RDONLY",
|
||||||
O_WRONLY from "O_WRONLY",
|
O_RDWR from "O_RDWR",
|
||||||
O_RDWR from "O_RDWR"
|
O_TRUNC from "O_TRUNC",
|
||||||
|
O_WRONLY from "O_WRONLY"
|
||||||
}
|
}
|
||||||
|
|
||||||
method(#primitive,#lenient) _open: path flags: flags.
|
method(#primitive,#lenient) _open: path flags: flags.
|
||||||
|
@ -7,132 +7,134 @@ class MyObject(Object)
|
|||||||
| errmsgs synerrmsgs f |
|
| errmsgs synerrmsgs f |
|
||||||
|
|
||||||
errmsgs := #(
|
errmsgs := #(
|
||||||
'no error'
|
"no error"
|
||||||
'generic error'
|
"generic error"
|
||||||
|
|
||||||
'not implemented'
|
"not implemented"
|
||||||
'subsystem error'
|
"subsystem error"
|
||||||
'internal error that should never have happened'
|
"internal error that should never have happened"
|
||||||
'insufficient system memory'
|
"insufficient system memory"
|
||||||
'insufficient object memory'
|
"insufficient object memory"
|
||||||
'invalid class/type'
|
"invalid class/type"
|
||||||
|
|
||||||
'invalid parameter or argument'
|
"invalid parameter or argument"
|
||||||
'data not found'
|
"data not found"
|
||||||
'existing/duplicate data'
|
"existing/duplicate data"
|
||||||
'busy'
|
"busy"
|
||||||
'access denied'
|
"access denied"
|
||||||
'operation not permitted'
|
"operation not permitted"
|
||||||
'not directory'
|
"not directory"
|
||||||
'interrupted'
|
"interrupted"
|
||||||
'pipe error'
|
"pipe error"
|
||||||
'resource temporarily unavailable'
|
"resource temporarily unavailable"
|
||||||
'bad system handle'
|
"bad system handle"
|
||||||
|
|
||||||
'*** undefined error ***'
|
"*** undefined error ***"
|
||||||
'message receiver error'
|
"message receiver error"
|
||||||
'message sending error'
|
"message sending error"
|
||||||
'wrong number of arguments'
|
"wrong number of arguments"
|
||||||
'range error'
|
"range error"
|
||||||
'byte-code full'
|
"byte-code full"
|
||||||
'dictionary full'
|
"dictionary full"
|
||||||
'processor full'
|
"processor full"
|
||||||
'too many semaphores'
|
"too many semaphores"
|
||||||
'*** undefined error ***'
|
"*** undefined error ***"
|
||||||
'divide by zero'
|
"divide by zero"
|
||||||
'I/O error'
|
"I/O error"
|
||||||
'encoding conversion error'
|
"encoding conversion error"
|
||||||
'insufficient data for encoding conversion'
|
"insufficient data for encoding conversion"
|
||||||
'buffer full'
|
"buffer full"
|
||||||
).
|
).
|
||||||
|
|
||||||
synerrmsgs := #(
|
synerrmsgs := #(
|
||||||
'no error'
|
"no error"
|
||||||
'illegal character'
|
"illegal character"
|
||||||
'comment not closed'
|
"comment not closed"
|
||||||
'string not closed'
|
"string not closed"
|
||||||
'no character after $'
|
"no character after $"
|
||||||
'no valid character after #'
|
"no valid character after #"
|
||||||
'no valid character after #\'
|
"no valid character after #\\"
|
||||||
'wrong character literal'
|
"wrong character literal"
|
||||||
'colon expected'
|
"colon expected"
|
||||||
'string expected'
|
"string expected"
|
||||||
'invalid radix'
|
"invalid radix"
|
||||||
'invalid integer literal'
|
"invalid integer literal"
|
||||||
'invalid fixed-point decimal scale'
|
"invalid fixed-point decimal scale"
|
||||||
'invalid fixed-point decimal literal'
|
"invalid fixed-point decimal literal"
|
||||||
'byte too small or too large'
|
"byte too small or too large"
|
||||||
'wrong error literal'
|
"wrong error literal"
|
||||||
'wrong smptr literal'
|
"wrong smptr literal"
|
||||||
'{ expected'
|
"{ expected"
|
||||||
'} expected'
|
"} expected"
|
||||||
'( expected'
|
"( expected"
|
||||||
') expected'
|
") expected"
|
||||||
'] expected'
|
"] expected"
|
||||||
'. expected'
|
". expected"
|
||||||
', expected'
|
", expected"
|
||||||
'| expected'
|
"| expected"
|
||||||
'> expected'
|
"> expected"
|
||||||
':= expected'
|
":= expected"
|
||||||
'identifier expected'
|
"identifier expected"
|
||||||
'integer expected'
|
"integer expected"
|
||||||
'primitive: expected'
|
"primitive: expected"
|
||||||
'wrong directive'
|
"wrong directive"
|
||||||
'wrong name'
|
"wrong name"
|
||||||
'duplicate name'
|
"duplicate name"
|
||||||
'undefined name'
|
"undefined name"
|
||||||
'contradictory class definition'
|
"contradictory class definition"
|
||||||
'class not conforming to interface'
|
"class not conforming to interface"
|
||||||
'invalid non-pointer instance size'
|
"invalid non-pointer instance size"
|
||||||
'prohibited inheritance'
|
"prohibited inheritance"
|
||||||
'variable declaration not allowed'
|
"variable declaration not allowed"
|
||||||
'modifier expected'
|
"modifier expected"
|
||||||
'wrong modifier'
|
"wrong modifier"
|
||||||
'disallowed modifier'
|
"disallowed modifier"
|
||||||
'duplicate modifier'
|
"duplicate modifier"
|
||||||
'method name expected'
|
"method name expected"
|
||||||
'duplicate method name'
|
"duplicate method name"
|
||||||
'invalid variadic method definition'
|
"invalid variadic method definition"
|
||||||
'variable name expected'
|
"variable name expected"
|
||||||
'duplicate argument name'
|
"duplicate argument name"
|
||||||
'duplicate temporary variable name'
|
"duplicate temporary variable name"
|
||||||
'duplicate variable name'
|
"duplicate variable name"
|
||||||
'duplicate block argument name'
|
"duplicate block argument name"
|
||||||
'undeclared variable'
|
"undeclared variable"
|
||||||
'unusable variable in compiled code'
|
"unusable variable in compiled code"
|
||||||
'inaccessible variable'
|
"inaccessible variable"
|
||||||
'ambiguous variable'
|
"ambiguous variable"
|
||||||
'too many instance/class variables'
|
"too many instance/class variables"
|
||||||
'inaccessible super'
|
"inaccessible super"
|
||||||
'wrong expression primary'
|
"wrong expression primary"
|
||||||
'too many temporaries'
|
"too many temporaries"
|
||||||
'too many arguments'
|
"too many arguments"
|
||||||
'too many block temporaries'
|
"too many block temporaries"
|
||||||
'too many block arguments'
|
"too many block arguments"
|
||||||
'array expression too large'
|
"array expression too large"
|
||||||
'instruction data too large'
|
"instruction data too large"
|
||||||
'wrong primitive function number'
|
"wrong primitive function number"
|
||||||
'wrong primitive function identifier'
|
"wrong primitive function identifier"
|
||||||
'wrong primitive function argument definition'
|
"wrong primitive function argument definition"
|
||||||
'failed to import module'
|
"wrong primitive value identifier"
|
||||||
'#include error'
|
"primitive value load from module not allowed"
|
||||||
'wrong pragma name'
|
"failed to import module"
|
||||||
'wrong namespace name'
|
"#include error"
|
||||||
'wrong pooldic import name'
|
"wrong pragma name"
|
||||||
'duplicate pooldic import name'
|
"wrong namespace name"
|
||||||
'literal expected'
|
"wrong pooldic import name"
|
||||||
'break or continue not within a loop'
|
"duplicate pooldic import name"
|
||||||
'break or continue within a block'
|
"literal expected"
|
||||||
'while expected'
|
"break or continue not within a loop"
|
||||||
'invalid goto target'
|
"break or continue within a block"
|
||||||
'label at end'
|
"while expected"
|
||||||
|
"invalid goto target"
|
||||||
|
"label at end"
|
||||||
).
|
).
|
||||||
|
|
||||||
f := Stdio open: 'generr.out' for: 'w'.
|
f := Stdio open: "generr.out" for: "w".
|
||||||
[ f isError ] ifTrue: [ System logNl: 'Cannot open generr.out'. thisProcess terminate. ].
|
[ f isError ] ifTrue: [ System logNl: "Cannot open generr.out". thisProcess terminate. ].
|
||||||
|
|
||||||
self emitMessages: errmsgs named: 'errstr' on: f.
|
self emitMessages: errmsgs named: "errstr" on: f.
|
||||||
self emitMessages: synerrmsgs named: 'synerrstr' on: f.
|
self emitMessages: synerrmsgs named: "synerrstr" on: f.
|
||||||
|
|
||||||
f close.
|
f close.
|
||||||
}
|
}
|
||||||
|
@ -5386,27 +5386,73 @@ static int read_array_literal (moo_t* moo, int rdonly, moo_oop_t* xlit)
|
|||||||
{
|
{
|
||||||
moo_oop_t lit, a;
|
moo_oop_t lit, a;
|
||||||
moo_oow_t i, j, saved_arlit_count;
|
moo_oow_t i, j, saved_arlit_count;
|
||||||
|
int comma_used = -1; /* unknown */
|
||||||
|
|
||||||
saved_arlit_count = moo->c->arlit.count;
|
saved_arlit_count = moo->c->arlit.count;
|
||||||
|
|
||||||
GET_TOKEN_GOTO (moo, oops); /* skip #( */
|
GET_TOKEN_GOTO (moo, oops); /* skip #( */
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (TOKEN_TYPE(moo) == MOO_IOTOK_EOF)
|
if (TOKEN_TYPE(moo) == MOO_IOTOK_EOF)
|
||||||
{
|
{
|
||||||
moo_setsynerr (moo, MOO_SYNERR_RPAREN, TOKEN_LOC(moo), TOKEN_NAME(moo));
|
moo_setsynerr (moo, MOO_SYNERR_RPAREN, TOKEN_LOC(moo), TOKEN_NAME(moo));
|
||||||
goto oops;
|
goto oops;
|
||||||
}
|
}
|
||||||
else if (TOKEN_TYPE(moo) == MOO_IOTOK_RPAREN) break;
|
else if (TOKEN_TYPE(moo) != MOO_IOTOK_RPAREN)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
lit = token_to_literal(moo, rdonly);
|
lit = token_to_literal(moo, rdonly);
|
||||||
if (!lit || add_to_array_literal_buffer(moo, lit) <= -1) goto oops;
|
if (!lit || add_to_array_literal_buffer(moo, lit) <= -1) goto oops;
|
||||||
|
|
||||||
GET_TOKEN_GOTO (moo, oops);
|
GET_TOKEN_GOTO (moo, oops);
|
||||||
|
if (TOKEN_TYPE(moo) == MOO_IOTOK_EOF || TOKEN_TYPE(moo) == MOO_IOTOK_RPAREN) break;
|
||||||
|
|
||||||
|
if (comma_used == -1)
|
||||||
|
{
|
||||||
|
/* check if a comma has been used after the first element */
|
||||||
|
if (TOKEN_TYPE(moo) == MOO_IOTOK_COMMA)
|
||||||
|
{
|
||||||
|
comma_used = 1;
|
||||||
|
goto literal_expected_after_comma;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
comma_used = 0;
|
||||||
|
if (TOKEN_TYPE(moo) == MOO_IOTOK_RPAREN || TOKEN_TYPE(moo) == MOO_IOTOK_EOF) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (comma_used == 0)
|
||||||
|
{
|
||||||
|
/* a comma is not expected. stop if EOF or ) is encountered */
|
||||||
|
if (TOKEN_TYPE(moo) == MOO_IOTOK_COMMA || TOKEN_TYPE(moo) == MOO_IOTOK_RPAREN || TOKEN_TYPE(moo) == MOO_IOTOK_EOF) break;
|
||||||
|
}
|
||||||
|
else if (comma_used == 1)
|
||||||
|
{
|
||||||
|
/* a comma is expected */
|
||||||
|
if (TOKEN_TYPE(moo) != MOO_IOTOK_COMMA)
|
||||||
|
{
|
||||||
|
moo_setsynerr (moo, MOO_SYNERR_COMMA, TOKEN_LOC(moo), TOKEN_NAME(moo));
|
||||||
|
goto oops;
|
||||||
|
}
|
||||||
|
|
||||||
|
literal_expected_after_comma:
|
||||||
|
GET_TOKEN_GOTO (moo, oops);
|
||||||
|
if (TOKEN_TYPE(moo) == MOO_IOTOK_COMMA || TOKEN_TYPE(moo) == MOO_IOTOK_RPAREN || TOKEN_TYPE(moo) == MOO_IOTOK_EOF)
|
||||||
|
{
|
||||||
|
moo_setsynerr (moo, MOO_SYNERR_LITERAL, TOKEN_LOC(moo), TOKEN_NAME(moo));
|
||||||
|
goto oops;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
while (1);
|
while (1);
|
||||||
|
|
||||||
|
if (TOKEN_TYPE(moo) != MOO_IOTOK_RPAREN)
|
||||||
|
{
|
||||||
|
moo_setsynerr (moo, MOO_SYNERR_RPAREN, TOKEN_LOC(moo), TOKEN_NAME(moo));
|
||||||
|
goto oops;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
a = moo_instantiate(moo, moo->_array, MOO_NULL, moo->c->arlit.count - saved_arlit_count);
|
a = moo_instantiate(moo, moo->_array, MOO_NULL, moo->c->arlit.count - saved_arlit_count);
|
||||||
if (!a) goto oops;
|
if (!a) goto oops;
|
||||||
|
|
||||||
|
@ -59,6 +59,8 @@ static moo_pfrc_t pf_open_file (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
|
|||||||
flags = MOO_STACK_GETARG(moo, nargs, 1);
|
flags = MOO_STACK_GETARG(moo, nargs, 1);
|
||||||
mode = (nargs < 3)? MOO_SMOOI_TO_OOP(0644): MOO_STACK_GETARG(moo, nargs, 2);
|
mode = (nargs < 3)? MOO_SMOOI_TO_OOP(0644): MOO_STACK_GETARG(moo, nargs, 2);
|
||||||
|
|
||||||
|
/* TODO: always set O_LARGEFILE on flags if necessary */
|
||||||
|
|
||||||
MOO_PF_CHECK_ARGS (moo, nargs, MOO_OBJ_IS_CHAR_POINTER(path) && MOO_OOP_IS_SMOOI(flags) && MOO_OOP_IS_SMOOI(mode));
|
MOO_PF_CHECK_ARGS (moo, nargs, MOO_OBJ_IS_CHAR_POINTER(path) && MOO_OOP_IS_SMOOI(flags) && MOO_OOP_IS_SMOOI(mode));
|
||||||
MOO_PF_CHECK_ARGS (moo, nargs, moo_count_oocstr(MOO_OBJ_GET_CHAR_SLOT(path)) == MOO_OBJ_GET_SIZE(path));
|
MOO_PF_CHECK_ARGS (moo, nargs, moo_count_oocstr(MOO_OBJ_GET_CHAR_SLOT(path)) == MOO_OBJ_GET_SIZE(path));
|
||||||
|
|
||||||
@ -124,10 +126,15 @@ static moo_pfinfo_t pfinfos[] =
|
|||||||
|
|
||||||
static moo_pvinfo_t pvinfos[] =
|
static moo_pvinfo_t pvinfos[] =
|
||||||
{
|
{
|
||||||
|
{ "O_CLOEXEC", { MOO_PV_INT, MOO_BQ(O_CLOEXEC) } },
|
||||||
|
{ "O_CREAT", { MOO_PV_INT, MOO_BQ(O_CREAT) } },
|
||||||
|
{ "O_EXCL", { MOO_PV_INT, MOO_BQ(O_EXCL) } },
|
||||||
|
{ "O_NOFOLLOW", { MOO_PV_INT, MOO_BQ(O_NOFOLLOW) } },
|
||||||
{ "O_NONBLOCK", { MOO_PV_INT, MOO_BQ(O_NONBLOCK) } },
|
{ "O_NONBLOCK", { MOO_PV_INT, MOO_BQ(O_NONBLOCK) } },
|
||||||
{ "O_RDONLY", { MOO_PV_INT, MOO_BQ(O_RDONLY) } },
|
{ "O_RDONLY", { MOO_PV_INT, MOO_BQ(O_RDONLY) } },
|
||||||
{ "O_RDWR", { MOO_PV_INT, MOO_BQ(O_RDWR) } },
|
{ "O_RDWR", { MOO_PV_INT, MOO_BQ(O_RDWR) } },
|
||||||
{ "O_WRONLY", { MOO_PV_INT, MOO_BQ(O_WRONLY) } }
|
{ "O_TRUNC", { MOO_PV_INT, MOO_BQ(O_TRUNC) } },
|
||||||
|
{ "O_WRONLY", { MOO_PV_INT, MOO_BQ(O_WRONLY) } },
|
||||||
};
|
};
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user