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)
{
dcl(#class) Q R.
dcl(#classinst) a1 a2.
var(#class) Q, R.
var(#classinst) a1, a2.
}
class MyObject(TestObject)
{
#declare(#classinst) t1 t2.
var(#classinst) t1, t2.
method(#class) xxxx
{
| g1 g2 |

View File

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

View File

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

View File

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

View File

@ -29,14 +29,14 @@ extend SmallInteger
class TestObject(Object)
{
dcl(#class) Q R.
dcl(#classinst) t1 t2.
var(#class) Q, R.
var(#classinst) t1, t2.
}
class MyObject(TestObject)
{
dcl(#class) C B A.
var(#class) C, B, A.
method getTrue
{
@ -116,11 +116,11 @@ class MyObject(TestObject)
#[ 1 2 3] dump.
#[ 4 5 6] dump.
#(abc:def: 2 'string is good' 3 4 (5 6) (7 (8 9)) 10) dump.
#([] #[]) dump.
#(#abc:def: 2 'string is good' 3 4 #(5 6) #(7 #(8 9)) 10) 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.
@ -224,10 +224,10 @@ class MyObject(TestObject)
[self getTen] value dump.
}
method(#class) abc
(*method(#class) abc
{
<primitive: #snd_open>
}
}*)
method(#class) a: a b: b c: c
{
@ -441,16 +441,16 @@ PROCESS TESTING
'====================' 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.] 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 notNil dump.
nil isNil dump.
nil notNil dump.
nil class dump.
nil class class class dump.
"
*)
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -29,8 +29,8 @@ extend SmallInteger
class TestObject(Object)
{
dcl(#class) Q R.
dcl(#classinst) a1 a2.
var(#class) Q, R.
var(#classinst) a1, a2.
method test999
{
@ -40,8 +40,8 @@ class TestObject(Object)
class B.TestObject(Object)
{
dcl(#class) Q R.
dcl(#classinst) a1 a2.
var(#class) Q, R.
var(#classinst) a1, a2.
method test000
{
@ -51,7 +51,7 @@ class B.TestObject(Object)
pooldic ABC
{
#KKK := 20.
KKK := 20.
}
@ -65,12 +65,12 @@ class MyObject(TestObject)
k := 99.
[
[
##[ Exception signal: 'simulated error' ] ensure: [('ensure 1 ', (k asString)) dump ].
[ ^ 20 ] ensure: [ ('ensure 1 ', (k asString)) dump. ].
##[ Exception signal: 'simulated error' ] ensure: [('ensure 1 ' & (k asString)) dump ].
[ ^ 20 ] ensure: [ ('ensure 1 ' & (k asString)) dump. ].
] ensure: ['ensure 2' dump ].
] ensure: ['ensure 3' dump ].
] on: Exception do: [:ex |
('EXCETION - ' , ex messageText) dump.
('EXCETION - ' & ex messageText) dump.
## Exception signal: 'qqq'.
].
^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' ] 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 := [
[
@ -103,7 +103,7 @@ class MyObject(TestObject)
[ '@@@@@' dump.
Exception signal: 'simulated error'.
'^^^^^^' dump. ] ensure: [
('ensure 11 ', (k asString)) dump.
('ensure 11 ' & (k asString)) dump.
Exception signal: 'qqq'.
].
@ -115,7 +115,7 @@ class MyObject(TestObject)
'JJJJJJJJJJJJJJJJJJJJJJJJJJJ' dump.
] ensure: ['ensure 3' dump ].
] on: Exception do: [:ex |
('>>>> EXCETION - ' , ex messageText) dump.
('>>>> EXCETION - ' & ex messageText) dump.
ex pass.
##Exception signal: 'XXXXXXXXXXXXx'.
@ -125,10 +125,10 @@ class MyObject(TestObject)
'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ' dump.
]
on: PrimitiveFailureException do: [:ex |
('PRIMITIVE FAILURE EXCETION AT OUTER - ' , ex messageText) dump.
('PRIMITIVE FAILURE EXCETION AT OUTER - ' & ex messageText) dump.
]
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)
{
dcl(#class) Q R.
dcl(#classinst) a1 a2.
var(#class) Q, R.
var(#classinst) a1, a2.
method test999
{
@ -40,8 +40,8 @@ class TestObject(Object)
class B.TestObject(Object)
{
dcl(#class) Q R.
dcl(#classinst) a1 a2.
var(#class) Q, R.
var(#classinst) a1, a2.
method test000
{
@ -51,7 +51,7 @@ class B.TestObject(Object)
pooldic ABC
{
#KKK := 20.
KKK := 20.
}
@ -67,7 +67,7 @@ class MyObject(TestObject)
]
on: Exception
do: [:ex |
System logNl: ('Exception: ', ex messageText).
System logNl: ('Exception: ' & ex messageText).
ex return: 10.
##ex retry.
System logNl: '--- THIS MUST NOT BE PRINTED ---'.

View File

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

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);
}
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);
GET_CHAR_TO (moo, c);
}
while (is_identchar(c));
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 */
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;
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);

View File

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