1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-02-21 08:29:13 +00:00

Allow array declaration to follow type, before identifier

This commit is contained in:
David Schmenk 2014-11-06 10:09:47 -08:00
parent d93dc08a5b
commit e95bd8bc00
3 changed files with 24 additions and 11 deletions

View File

@ -40,8 +40,8 @@ for iter = 1 to 10
k = k + prime k = k + prime
loop loop
count = count + 1 count = count + 1
;puti(prime) // puti(prime)
;putln // putln
fin fin
next next
next next

View File

@ -5,17 +5,19 @@ include(stdlib.plh)
include(testlib.plh) include(testlib.plh)
// //
// Declare all global variables for this module. // Declare all global variables for this module.
// Note that arrays are declared with prefix []. postfix [], or no [].
// Only arrays with predclared sizes need [ and ], such as "int[3] a".
// //
byte hello[] = "Hello, Apple " byte[] hello = "Hello, Apple "
byte a1[] = "1" byte[] a1 = "1"
byte a2[] = "][" byte[] a2 = "]["
byte a2p[] = "][+" byte[] a2p = "][+"
byte a2e[] = "//e" byte[] a2e = "//e"
byte a2c[] = "//c" byte[] a2c = "//c"
byte a3[] = "///" byte[] a3 = "///"
word struct[] = 1, 10, 100, 1000, 10000 word struct[] = 1, 10, 100, 1000, 10000
word ptr word ptr
byte spaces[] = " " byte spaces = " "
// //
// Define functions. // Define functions.
// //

View File

@ -983,7 +983,18 @@ int parse_var(int type)
int consttype, constsize, arraysize, idlen = 0; int consttype, constsize, arraysize, idlen = 0;
long size = 1; long size = 1;
if (scan() == ID_TOKEN) if (scan() == OPEN_BRACKET_TOKEN)
{
size = 0;
parse_constexpr(&size, &constsize);
if (scantoken != CLOSE_BRACKET_TOKEN)
{
parse_error("Missing closing bracket");
return (0);
}
scan();
}
if (scantoken == ID_TOKEN)
{ {
idstr = tokenstr; idstr = tokenstr;
idlen = tokenlen; idlen = tokenlen;