fixed a lexer bug of eating up one more character when reading a single-letter identifier C, S, M followed by a non-identifier letter in get_ident().

changed various test programs according to syntax changes
This commit is contained in:
hyunghwan.chung 2017-04-24 09:20:27 +00:00
parent 5bf8d20a93
commit 8a0d476d18
16 changed files with 98 additions and 80 deletions

View File

@ -29,14 +29,14 @@ extend SmallInteger
class TestObject(Object) class TestObject(Object)
{ {
dcl(#class) Q R. var(#class) Q, R.
dcl(#classinst) a1 a2. var(#classinst) a1, a2.
} }
class MyObject(TestObject) class MyObject(TestObject)
{ {
#declare(#classinst) t1 t2. var(#classinst) t1, t2.
method(#class) xxxx method(#class) xxxx
{ {
| g1 g2 | | g1 g2 |

View File

@ -29,14 +29,14 @@ extend SmallInteger
class TestObject(Object) class TestObject(Object)
{ {
dcl(#class) Q R. var(#class) Q, R.
dcl(#classinst) a1 a2. var(#classinst) a1, a2.
} }
class MyObject(TestObject) class MyObject(TestObject)
{ {
#declare(#classinst) t1 t2. var(#classinst) t1, t2.
method(#class) xxxx method(#class) xxxx
{ {
| g1 g2 | | g1 g2 |

View File

@ -29,14 +29,15 @@ extend SmallInteger
class TestObject(Object) class TestObject(Object)
{ {
dcl(#class) Q R. var(#class) Q, R.
dcl(#classinst) a1 a2. var(#classinst) a1, a2.
} }
class MyObject(TestObject) class MyObject(TestObject)
{ {
#declare(#classinst) t1 t2. var(#classinst) t1, t2.
method(#class) xxxx method(#class) xxxx
{ {
| g1 g2 | | g1 g2 |

View File

@ -29,14 +29,15 @@ extend SmallInteger
class TestObject(Object) class TestObject(Object)
{ {
dcl(#class) Q R. var(#class) Q, R.
dcl(#classinst) a1 a2. var(#classinst) a1, a2.
} }
class MyObject(TestObject) class MyObject(TestObject)
{ {
#declare(#classinst) t1 t2. var(#classinst) t1, t2.
method(#class) xxxx method(#class) xxxx
{ {
| g1 g2 | | g1 g2 |

View File

@ -29,14 +29,14 @@ extend SmallInteger
class TestObject(Object) class TestObject(Object)
{ {
dcl(#class) Q R. var(#class) Q, R.
dcl(#classinst) t1 t2. var(#classinst) t1, t2.
} }
class MyObject(TestObject) class MyObject(TestObject)
{ {
dcl(#class) C B A. var(#class) C, B, A.
method getTrue method getTrue
{ {
@ -116,11 +116,11 @@ class MyObject(TestObject)
#[ 1 2 3] dump. #[ 1 2 3] dump.
#[ 4 5 6] dump. #[ 4 5 6] dump.
#(abc:def: 2 'string is good' 3 4 (5 6) (7 (8 9)) 10) dump. #(#abc:def: 2 'string is good' 3 4 #(5 6) #(7 #(8 9)) 10) dump.
#([] #[]) dump. #(#[] #[]) dump.
a := #(abc:def: -2 'string is good' 3 #[2 3 4] 4 (5 6) (7 (8 [4 56] 'hello' 9)) 10 -93952 self true false nil thisContext super). a := #(#abc:def: -2 'string is good' 3 #[2 3 4] 4 #(5 6) #(7 #(8 #[4 56] 'hello' 9)) 10 -93952 #self true false nil #thisContext #super).
a at: 3 put: 'hello world'; dump. a at: 3 put: 'hello world'; dump.
@ -224,10 +224,10 @@ class MyObject(TestObject)
[self getTen] value dump. [self getTen] value dump.
} }
method(#class) abc (*method(#class) abc
{ {
<primitive: #snd_open> <primitive: #snd_open>
} }*)
method(#class) a: a b: b c: c method(#class) a: a b: b c: c
{ {
@ -441,16 +441,16 @@ PROCESS TESTING
'====================' dump. '====================' dump.
[ :a :b | a dump. b dump. a := 20. b := [ a + 20 ]. b value.] value dump. ## not sufficient arguments. it must fail [ :a :b | a dump. b dump. a := 20. b := [ a + 20 ]. b value.] value dump. ## not sufficient arguments. it must fail
"[ :a :b | a dump. b dump. a := 20. b := [ a + 20 ]. b value.] on: Exception do: [:ex | 'Exception' dump]." ##[ :a :b | a dump. b dump. a := 20. b := [ a + 20 ]. b value.] on: Exception do: [:ex | 'Exception' dump].
" (*
FFI isNil dump. FFI isNil dump.
FFI notNil dump. FFI notNil dump.
nil isNil dump. nil isNil dump.
nil notNil dump. nil notNil dump.
nil class dump. nil class dump.
nil class class class dump. nil class class class dump.
" *)
} }
} }

View File

@ -29,14 +29,14 @@ extend SmallInteger
class TestObject(Object) class TestObject(Object)
{ {
dcl(#class) Q R. var(#class) Q, R.
dcl(#classinst) t1 t2. var(#classinst) t1, t2.
} }
class MyObject(TestObject) class MyObject(TestObject)
{ {
dcl(#class) C B A. var(#class) C, B, A.
method getTrue method getTrue
{ {

View File

@ -29,14 +29,14 @@ extend SmallInteger
class TestObject(Object) class TestObject(Object)
{ {
dcl(#class) Q R. var(#class) Q, R.
dcl(#classinst) t1 t2. var(#classinst) t1, t2.
} }
class MyObject(TestObject) class MyObject(TestObject)
{ {
dcl(#class) C B A. var(#class) C, B, A.
method getTrue method getTrue
{ {
@ -65,11 +65,11 @@ class MyObject(TestObject)
{ {
| p p2 | | p p2 |
'START OF MAIN' dump. 'START OF MAIN' dump.
##p := [ :a :b :c :d | a dump. b dump. (c + d) dump. ^10. ] newProcessWith: #(abc def 10 20). ##p := [ :a :b :c :d | a dump. b dump. (c + d) dump. ^10. ] newProcessWith: #(#abc #def 10 20).
p := [ :a :b :c :d | a dump. b dump. (c + d) dump. ] newProcessWith: #(abc def 10 20). p := [ :a :b :c :d | a dump. b dump. (c + d) dump. ] newProcessWith: #(#abc #def 10 20).
p2 := [ :a :b :c :d | a dump. b dump. a dump. b dump. (c + d) dump. ^10000 ] newProcessWith: #( p2 := [ :a :b :c :d | a dump. b dump. a dump. b dump. (c + d) dump. ^10000 ] newProcessWith: #(
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA #AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB #BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
1000000000000000 1000000000000000
299999999999999999999999999999999999999999 299999999999999999999999999999999999999999
). ).

View File

@ -29,14 +29,14 @@ extend SmallInteger
class TestObject(Object) class TestObject(Object)
{ {
dcl(#class) Q R. var(#class) Q, R.
dcl(#classinst) a1 a2. var(#classinst) a1, a2.
} }
class MyObject(TestObject) class MyObject(TestObject)
{ {
#declare(#classinst) t1 t2 t3. var(#classinst) t1, t2, t3.
method(#class) xxxx method(#class) xxxx
{ {
| g1 g2 | | g1 g2 |
@ -57,9 +57,6 @@ class MyObject(TestObject)
t2 := t2 value. t2 := t2 value.
'END OF t2 value' dump. 'END OF t2 value' dump.
t2 dump. t2 dump.
} }
} }

View File

@ -29,14 +29,14 @@ extend SmallInteger
class TestObject(Object) class TestObject(Object)
{ {
dcl(#class) Q R. var(#class) Q, R.
dcl(#classinst) a1 a2. var(#classinst) a1, a2.
} }
class MyObject(TestObject) class MyObject(TestObject)
{ {
#declare(#classinst) t1 t2. var(#classinst) t1, t2.
method(#class) main2 method(#class) main2
{ {

View File

@ -29,8 +29,8 @@ extend SmallInteger
class TestObject(Object) class TestObject(Object)
{ {
dcl(#class) Q R. var(#class) Q, R.
dcl(#classinst) a1 a2. var(#classinst) a1, a2.
method test999 method test999
{ {
@ -40,8 +40,8 @@ class TestObject(Object)
class B.TestObject(Object) class B.TestObject(Object)
{ {
dcl(#class) Q R. var(#class) Q, R.
dcl(#classinst) a1 a2. var(#classinst) a1, a2.
method test000 method test000
{ {
@ -51,7 +51,7 @@ class B.TestObject(Object)
pooldic ABC pooldic ABC
{ {
#KKK := 20. KKK := 20.
} }

View File

@ -29,8 +29,8 @@ extend SmallInteger
class TestObject(Object) class TestObject(Object)
{ {
dcl(#class) Q R. var(#class) Q, R.
dcl(#classinst) a1 a2. var(#classinst) a1, a2.
} }

View File

@ -29,8 +29,8 @@ extend SmallInteger
class TestObject(Object) class TestObject(Object)
{ {
dcl(#class) Q R. var(#class) Q, R.
dcl(#classinst) a1 a2. var(#classinst) a1, a2.
method test999 method test999
{ {
@ -40,8 +40,8 @@ class TestObject(Object)
class B.TestObject(Object) class B.TestObject(Object)
{ {
dcl(#class) Q R. var(#class) Q, R.
dcl(#classinst) a1 a2. var(#classinst) a1, a2.
method test000 method test000
{ {
@ -51,7 +51,7 @@ class B.TestObject(Object)
pooldic ABC pooldic ABC
{ {
#KKK := 20. KKK := 20.
} }
@ -65,12 +65,12 @@ class MyObject(TestObject)
k := 99. k := 99.
[ [
[ [
##[ Exception signal: 'simulated error' ] ensure: [('ensure 1 ', (k asString)) dump ]. ##[ Exception signal: 'simulated error' ] ensure: [('ensure 1 ' & (k asString)) dump ].
[ ^ 20 ] ensure: [ ('ensure 1 ', (k asString)) dump. ]. [ ^ 20 ] ensure: [ ('ensure 1 ' & (k asString)) dump. ].
] ensure: ['ensure 2' dump ]. ] ensure: ['ensure 2' dump ].
] ensure: ['ensure 3' dump ]. ] ensure: ['ensure 3' dump ].
] on: Exception do: [:ex | ] on: Exception do: [:ex |
('EXCETION - ' , ex messageText) dump. ('EXCETION - ' & ex messageText) dump.
## Exception signal: 'qqq'. ## Exception signal: 'qqq'.
]. ].
^v1 ^v1
@ -88,11 +88,11 @@ class MyObject(TestObject)
##[ Exception signal: 'simulated error' ] on: Exception do: [:ex | 'CAUGHT...' dump. Exception signal: 'jjjjjjj' ]. ##[ Exception signal: 'simulated error' ] on: Exception do: [:ex | 'CAUGHT...' dump. Exception signal: 'jjjjjjj' ].
"[ (*[
[ Exception signal: 'simulated error' ] ensure: ['ensure 1' dump ]. [ Exception signal: 'simulated error' ] ensure: ['ensure 1' dump ].
] on: Exception do: [:ex | ('EXCETION - ' , ex messageText) dump. Exception signal: 'qqq'. ]." ] on: Exception do: [:ex | ('EXCETION - ' & ex messageText) dump. Exception signal: 'qqq'. ].
"[1 xxx] ifCurtailed: ['XXXXXXXX CURTAILED XXXXXXXXX' dump. Exception signal: 'jjjj']." [1 xxx] ifCurtailed: ['XXXXXXXX CURTAILED XXXXXXXXX' dump. Exception signal: 'jjjj']. *)
v1 := [ v1 := [
[ [
@ -103,7 +103,7 @@ class MyObject(TestObject)
[ '@@@@@' dump. [ '@@@@@' dump.
Exception signal: 'simulated error'. Exception signal: 'simulated error'.
'^^^^^^' dump. ] ensure: [ '^^^^^^' dump. ] ensure: [
('ensure 11 ', (k asString)) dump. ('ensure 11 ' & (k asString)) dump.
Exception signal: 'qqq'. Exception signal: 'qqq'.
]. ].
@ -115,7 +115,7 @@ class MyObject(TestObject)
'JJJJJJJJJJJJJJJJJJJJJJJJJJJ' dump. 'JJJJJJJJJJJJJJJJJJJJJJJJJJJ' dump.
] ensure: ['ensure 3' dump ]. ] ensure: ['ensure 3' dump ].
] on: Exception do: [:ex | ] on: Exception do: [:ex |
('>>>> EXCETION - ' , ex messageText) dump. ('>>>> EXCETION - ' & ex messageText) dump.
ex pass. ex pass.
##Exception signal: 'XXXXXXXXXXXXx'. ##Exception signal: 'XXXXXXXXXXXXx'.
@ -125,10 +125,10 @@ class MyObject(TestObject)
'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ' dump. 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ' dump.
] ]
on: PrimitiveFailureException do: [:ex | on: PrimitiveFailureException do: [:ex |
('PRIMITIVE FAILURE EXCETION AT OUTER - ' , ex messageText) dump. ('PRIMITIVE FAILURE EXCETION AT OUTER - ' & ex messageText) dump.
] ]
on: Exception do: [:ex | on: Exception do: [:ex |
('>>>> EXCETION AT OUTER - ' , ex messageText) dump. ('>>>> EXCETION AT OUTER - ' & ex messageText) dump.
]. ].

View File

@ -29,8 +29,8 @@ extend SmallInteger
class TestObject(Object) class TestObject(Object)
{ {
dcl(#class) Q R. var(#class) Q, R.
dcl(#classinst) a1 a2. var(#classinst) a1, a2.
method test999 method test999
{ {
@ -40,8 +40,8 @@ class TestObject(Object)
class B.TestObject(Object) class B.TestObject(Object)
{ {
dcl(#class) Q R. var(#class) Q, R.
dcl(#classinst) a1 a2. var(#classinst) a1, a2.
method test000 method test000
{ {
@ -51,7 +51,7 @@ class B.TestObject(Object)
pooldic ABC pooldic ABC
{ {
#KKK := 20. KKK := 20.
} }
@ -67,7 +67,7 @@ class MyObject(TestObject)
] ]
on: Exception on: Exception
do: [:ex | do: [:ex |
System logNl: ('Exception: ', ex messageText). System logNl: ('Exception: ' & ex messageText).
ex return: 10. ex return: 10.
##ex retry. ##ex retry.
System logNl: '--- THIS MUST NOT BE PRINTED ---'. System logNl: '--- THIS MUST NOT BE PRINTED ---'.

View File

@ -29,8 +29,8 @@ extend SmallInteger
class TestObject(Object) class TestObject(Object)
{ {
dcl(#class) Q R. var(#class) Q, R.
dcl(#classinst) a1 a2. var(#classinst) a1, a2.
method test999 method test999
{ {
@ -40,8 +40,8 @@ class TestObject(Object)
class B.TestObject(Object) class B.TestObject(Object)
{ {
dcl(#class) Q R. dcl(#class) Q, R.
dcl(#classinst) a1 a2. dcl(#classinst) a1, a2.
method test000 method test000
{ {
@ -90,7 +90,8 @@ class MyConsole(Console)
class MyObject(TestObject) class MyObject(TestObject)
{ {
dcl(#pooldic) ABC SRX.ABC. ##import(#pooldic) ABC, SRX.ABC.
import ABC, SRX.ABC.
method(#class) main method(#class) main
{ {

View File

@ -945,12 +945,13 @@ static int get_ident (moo_t* moo, moo_ooci_t char_read_ahead)
ADD_TOKEN_CHAR(moo, char_read_ahead); ADD_TOKEN_CHAR(moo, char_read_ahead);
} }
do /* while() instead of do..while() because when char_read_ahead is not EOF
* c may not be a identifier character */
while (is_identchar(c))
{ {
ADD_TOKEN_CHAR (moo, c); ADD_TOKEN_CHAR (moo, c);
GET_CHAR_TO (moo, c); GET_CHAR_TO (moo, c);
} }
while (is_identchar(c));
if (c == '(' && is_token_word(moo, VOCA_ERROR)) if (c == '(' && is_token_word(moo, VOCA_ERROR))
{ {
@ -3322,10 +3323,27 @@ static int compile_class_level_imports (moo_t* moo)
/* it falls back to the name space of the class */ /* it falls back to the name space of the class */
ns_oop = moo->c->cls.ns_oop; ns_oop = moo->c->cls.ns_oop;
} }
else break; else if (TOKEN_TYPE(moo) == MOO_IOTOK_COMMA || TOKEN_TYPE(moo) == MOO_IOTOK_EOF || TOKEN_TYPE(moo) == MOO_IOTOK_PERIOD)
{
/* no variable name is present */
set_syntax_error (moo, MOO_SYNERR_VARNAMEDUPL, TOKEN_LOC(moo), TOKEN_NAME(moo));
return -1;
}
else
{
break;
}
if (import_pool_dictionary(moo, ns_oop, &last, TOKEN_NAME(moo), TOKEN_LOC(moo)) <= -1) return -1; if (import_pool_dictionary(moo, ns_oop, &last, TOKEN_NAME(moo), TOKEN_LOC(moo)) <= -1) return -1;
GET_TOKEN (moo); GET_TOKEN (moo);
if (TOKEN_TYPE(moo) == MOO_IOTOK_IDENT_DOTTED || TOKEN_TYPE(moo) == MOO_IOTOK_IDENT)
{
set_syntax_error (moo, MOO_SYNERR_COMMA, TOKEN_LOC(moo), TOKEN_NAME(moo));
return -1;
}
else if (TOKEN_TYPE(moo) != MOO_IOTOK_COMMA) break; /* hopefully . */
GET_TOKEN (moo);
} }
while (1); while (1);

View File

@ -104,7 +104,7 @@
/* the old intel c code builder doesn't support __FUNCTION__ */ /* the old intel c code builder doesn't support __FUNCTION__ */
# define __PRIMITIVE_NAME__ "<<primitive>>" # define __PRIMITIVE_NAME__ "<<primitive>>"
#else #else
# define __PRIMITIVE_NAME__ (&__FUNCTION__[4]) # define __PRIMITIVE_NAME__ (&__FUNCTION__[0])
#endif #endif
static void signal_io_semaphore (moo_t* moo, moo_ooi_t mask, void* ctx); static void signal_io_semaphore (moo_t* moo, moo_ooi_t mask, void* ctx);