changed to accept identifer instead of symbols in pooldic definition

This commit is contained in:
hyunghwan.chung 2017-03-08 13:53:41 +00:00
parent 1ebfe8d5e9
commit 308318b615
3 changed files with 62 additions and 23 deletions

View File

@ -408,30 +408,33 @@ class UndefinedObject(Apex)
}
pooldic ErrorCode
class Error(Apex)
{
(* migrate it into Error class *)
#NONE := error(0).
#GENERIC := error(1).
#NOIMPL := error(2).
#SYSERR := error(3).
#INTERN := error(4).
#SYSMEM := error(5).
#OOMEM := error(6).
#INVAL := error(7).
#NOENT := error(8).
}
pooldic Error.Code
{
GENERIC := error(0).
NOIMPL := error(1).
SYSERR := error(2).
INTERN := error(3).
SYSMEM := error(4).
OOMEM := error(5).
INVAL := error(6).
NOENT := error(7).
(* add more items... *)
}
class Error(Apex)
extend Error
{
(* ----------------------------
TODO: support constant declaration...
#const
{
#NONE := error(0).
#GENERIC := error(1).
NONE := error(0).
GENERIC := error(1).
}
-------------------------------- *)

View File

@ -1,6 +1,42 @@
class Collection(Object)
{
method isEmpty
{
^self size <= 0
}
method notEmpty
{
^self size > 0
}
method size
{
(* Each subclass must override this method because
* it interates over the all elements for counting *)
| count |
count := 0.
self do: [ :el | count := count + 1 ].
^count
}
method do: block
{
^self subclassResponsibility: #do
}
method detect: block
{
self do: [ :el | if (block value: el) { ^el } ].
^Error.Code.NOENT
}
method detect: block ifNone: exception_block
{
self do: [ :el | if (block value: el) { ^el } ].
^exception_block value.
}
}
## -------------------------------------------------------------------------------
@ -193,7 +229,7 @@ class Set(Collection)
}.
##upsert ifFalse: [^ErrorCode.NOENT].
if (upsert) {} else { ^ErrorCode.NOENT }.
if (upsert) {} else { ^Error.Code.NOENT }.
ntally := self.tally + 1.
if (ntally >= bs)
@ -280,7 +316,7 @@ class Set(Collection)
index := (index + 1) rem: bs.
}.
^ErrorCode.NOENT.
^Error.Code.NOENT.
}
method __remove_at: index
@ -472,11 +508,11 @@ pooldic Log
## these items must follow defintions in moo.h
## -----------------------------------------------------------
#DEBUG := 1.
#INFO := 2.
#WARN := 4.
#ERROR := 8.
#FATAL := 16.
DEBUG := 1.
INFO := 2.
WARN := 4.
ERROR := 8.
FATAL := 16.
}
class SystemDictionary(Set)

View File

@ -6630,9 +6630,9 @@ static int __compile_pooldic_definition (moo_t* moo)
GET_TOKEN (moo);
while (TOKEN_TYPE(moo) == MOO_IOTOK_SYMLIT)
while (TOKEN_TYPE(moo) == MOO_IOTOK_IDENT)
{
lit = moo_makesymbol (moo, TOKEN_NAME_PTR(moo) + 1, TOKEN_NAME_LEN(moo) - 1);
lit = moo_makesymbol (moo, TOKEN_NAME_PTR(moo), TOKEN_NAME_LEN(moo));
if (!lit || add_to_array_literal_buffer (moo, lit) <= -1) return -1;
GET_TOKEN (moo);