Added parser for real numbers

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/steptalk/trunk@15315 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Stefan Urbanek 2002-12-21 22:13:15 +00:00
parent 7f837862b8
commit dbf32c0fc3
16 changed files with 326 additions and 174 deletions

View file

@ -1,3 +1,9 @@
2002 Dec 21
* Languages/GNUmakefile, Modules/GNUmakefile, Finders/GNUmakefile: removed
forced installation to the GNUSTEP_USER_ROOT. ~/Library/StepTalk/* should
be deleted.
2002 Nov 29
* Added GDL2 module

View file

@ -22,8 +22,6 @@
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
#
GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_USER_ROOT)
GNUSTEP_MAKEFILES = $(GNUSTEP_SYSTEM_ROOT)/Makefiles
include $(GNUSTEP_MAKEFILES)/common.make

View file

@ -22,8 +22,6 @@
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
#
GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_USER_ROOT)
GNUSTEP_MAKEFILES = $(GNUSTEP_SYSTEM_ROOT)/Makefiles
include $(GNUSTEP_MAKEFILES)/common.make

View file

@ -1,3 +1,11 @@
2002 Dec 21
* STSourceReader, STCompiler, STGrammar: Added real number parsing
2002 Sep 15
* Version 0.6.1
2002 Aug 30
* Code cleanup.

View file

@ -74,6 +74,7 @@
id retval = nil;
int i;
/* FIXME: step < 0? */
for(i=[self intValue];i<=number;i+=step)
{
retval = [block valueWith:[NSNumber numberWithInt:i]];

View file

@ -93,7 +93,8 @@ typedef struct _STParserContext
Class stringLiteralClass; /* default: NSMutableString */
Class arrayLiteralClass; /* default: NSMutableArray */
Class characterLiteralClass; /* default: NSString */
Class numberLiteralClass; /* default: NSNumber */
Class intNumberLiteralClass; /* default: NSNumber */
Class realNumberLiteralClass; /* default: NSNumber */
Class symbolLiteralClass; /* default: NSString */
}
/*" Environment "*/

View file

@ -100,7 +100,8 @@ extern int STCparse(void *context);
arrayLiteralClass = [NSMutableArray class];
stringLiteralClass = [NSMutableString class];
/* bytesLiteralClass = [NSMutableData class]; */
numberLiteralClass = [NSNumber class];
intNumberLiteralClass = [NSNumber class];
realNumberLiteralClass = [NSNumber class];
symbolLiteralClass = [STSelector class];
characterLiteralClass = [NSString class];
@ -650,9 +651,13 @@ extern int STCparse(void *context);
{
return arrayLiteralClass;
}
- (Class)numberLiteralClass
- (Class)intNumberLiteralClass
{
return numberLiteralClass;
return intNumberLiteralClass;
}
- (Class)realNumberLiteralClass
{
return realNumberLiteralClass;
}
- (Class)symbolLiteralClass
{
@ -670,9 +675,13 @@ extern int STCparse(void *context);
{
arrayLiteralClass = aClass;
}
- (void)setNumberLiteralClass:(Class)aClass
- (void)setIntNumberLiteralClass:(Class)aClass
{
numberLiteralClass = aClass;
intNumberLiteralClass = aClass;
}
- (void)setRealNumberLiteralClass:(Class)aClass
{
realNumberLiteralClass = aClass;
}
- (void)setSymbolLiteralClass:(Class)aClass
{
@ -683,9 +692,13 @@ extern int STCparse(void *context);
characterLiteralClass = aClass;
}
- (id)createNumberLiteralFrom:(NSString *)aString
- (id)createIntNumberLiteralFrom:(NSString *)aString
{
return [numberLiteralClass numberFromString:aString];
return [intNumberLiteralClass intNumberFromString:aString];
}
- (id)createRealNumberLiteralFrom:(NSString *)aString
{
return [realNumberLiteralClass realNumberFromString:aString];
}
- (id)createSymbolLiteralFrom:(NSString *)aString
{

View file

@ -350,11 +350,14 @@
@end
@implementation NSNumber(STCompilerAdditions)
+ (id) numberFromString:(NSString *)aString
+ (id) intNumberFromString:(NSString *)aString
{
/* FIXME: handle all formats */
return [self numberWithInt:[aString intValue]];
}
+ (id) realNumberFromString:(NSString *)aString
{
return [self numberWithDouble:[aString doubleValue]];
}
@end
@implementation NSMutableArray(STCompilerAdditions)

View file

@ -25,10 +25,11 @@
# define TK_IDENTIFIER 269
# define TK_BINARY_SELECTOR 270
# define TK_KEYWORD 271
# define TK_NUMBER 272
# define TK_SYMBOL 273
# define TK_STRING 274
# define TK_CHARACTER 275
# define TK_INTNUMBER 272
# define TK_REALNUMBER 273
# define TK_SYMBOL 274
# define TK_STRING 275
# define TK_CHARACTER 276
#line 25 "STGrammar.y"
@ -67,12 +68,12 @@
#define YYFINAL 115
#define YYFINAL 116
#define YYFLAG -32768
#define YYNTBASE 22
#define YYNTBASE 23
/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
#define YYTRANSLATE(x) ((unsigned)(x) <= 275 ? yytranslate[x] : 57)
#define YYTRANSLATE(x) ((unsigned)(x) <= 276 ? yytranslate[x] : 58)
/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
static const char yytranslate[] =
@ -104,7 +105,7 @@ static const char yytranslate[] =
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 1, 3, 4, 5,
6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21
16, 17, 18, 19, 20, 21, 22
};
#if YYDEBUG
@ -117,32 +118,33 @@ static const short yyprhs[] =
115, 118, 121, 124, 128, 130, 133, 135, 137, 139,
141, 144, 148, 151, 154, 158, 160, 162, 164, 166,
168, 170, 172, 176, 178, 180, 182, 184, 186, 188,
190, 192, 196, 197, 199, 201, 204, 207, 209, 211
190, 192, 194, 198, 199, 201, 203, 206, 209, 211,
213
};
static const short yyrhs[] =
{
-1, 23, 0, 8, 4, 24, 9, 0, 34, 0,
30, 34, 0, 0, 33, 25, 26, 0, 26, 0,
27, 0, 26, 3, 27, 0, 28, 34, 0, 28,
30, 34, 0, 51, 0, 52, 50, 0, 29, 0,
53, 50, 0, 29, 53, 50, 0, 4, 31, 4,
0, 50, 0, 31, 50, 0, 8, 9, 0, 8,
34, 9, 0, 8, 33, 4, 34, 9, 0, 12,
50, 0, 33, 12, 50, 0, 14, 36, 0, 35,
0, 35, 11, 0, 35, 11, 14, 36, 0, 36,
0, 35, 11, 36, 0, 49, 0, 37, 49, 0,
42, 0, 37, 42, 0, 39, 0, 37, 39, 0,
38, 0, 37, 38, 0, 50, 5, 0, 42, 40,
0, 13, 41, 0, 40, 13, 41, 0, 51, 0,
52, 47, 0, 46, 0, 43, 0, 44, 0, 45,
0, 47, 51, 0, 48, 52, 47, 0, 48, 46,
0, 53, 48, 0, 46, 53, 48, 0, 49, 0,
43, 0, 47, 0, 44, 0, 50, 0, 54, 0,
32, 0, 6, 36, 7, 0, 15, 0, 15, 0,
-1, 24, 0, 8, 4, 25, 9, 0, 35, 0,
31, 35, 0, 0, 34, 26, 27, 0, 27, 0,
28, 0, 27, 3, 28, 0, 29, 35, 0, 29,
31, 35, 0, 52, 0, 53, 51, 0, 30, 0,
54, 51, 0, 30, 54, 51, 0, 4, 32, 4,
0, 51, 0, 32, 51, 0, 8, 9, 0, 8,
35, 9, 0, 8, 34, 4, 35, 9, 0, 12,
51, 0, 34, 12, 51, 0, 14, 37, 0, 36,
0, 36, 11, 0, 36, 11, 14, 37, 0, 37,
0, 36, 11, 37, 0, 50, 0, 38, 50, 0,
43, 0, 38, 43, 0, 40, 0, 38, 40, 0,
39, 0, 38, 39, 0, 51, 5, 0, 43, 41,
0, 13, 42, 0, 41, 13, 42, 0, 52, 0,
53, 48, 0, 47, 0, 44, 0, 45, 0, 46,
0, 48, 52, 0, 49, 53, 48, 0, 49, 47,
0, 54, 49, 0, 47, 54, 49, 0, 50, 0,
44, 0, 48, 0, 45, 0, 51, 0, 55, 0,
33, 0, 6, 37, 7, 0, 15, 0, 15, 0,
16, 0, 17, 0, 18, 0, 19, 0, 20, 0,
21, 0, 10, 55, 7, 0, 0, 54, 0, 56,
0, 55, 54, 0, 55, 56, 0, 15, 0, 52,
0, 17, 0
21, 0, 22, 0, 10, 56, 7, 0, 0, 55,
0, 57, 0, 56, 55, 0, 56, 57, 0, 15,
0, 53, 0, 17, 0
};
#endif
@ -157,8 +159,9 @@ static const short yyrline[] =
219, 225, 231, 236, 242, 243, 248, 249, 255, 260,
267, 270, 276, 281, 287, 292, 297, 300, 301, 302,
304, 313, 322, 329, 334, 340, 341, 343, 344, 346,
350, 354, 358, 363, 365, 367, 369, 371, 373, 375,
377, 379, 382, 383, 385, 387, 388, 390, 392, 394
350, 354, 358, 363, 365, 367, 369, 371, 374, 376,
378, 380, 382, 385, 386, 388, 390, 391, 393, 395,
397
};
#endif
@ -171,11 +174,11 @@ static const char *const yytname[] =
"$", "error", "$undefined.", "TK_SEPARATOR", "TK_BAR", "TK_ASSIGNMENT",
"TK_LPAREN", "TK_RPAREN", "TK_BLOCK_OPEN", "TK_BLOCK_CLOSE",
"TK_ARRAY_OPEN", "TK_DOT", "TK_COLON", "TK_SEMICOLON", "TK_RETURN",
"TK_IDENTIFIER", "TK_BINARY_SELECTOR", "TK_KEYWORD", "TK_NUMBER",
"TK_SYMBOL", "TK_STRING", "TK_CHARACTER", "source", "single_method",
"methods", "@1", "method_list", "method", "message_pattern",
"keyword_list", "temporaries", "variable_list", "block",
"block_var_list", "statements", "expressions", "expression",
"TK_IDENTIFIER", "TK_BINARY_SELECTOR", "TK_KEYWORD", "TK_INTNUMBER",
"TK_REALNUMBER", "TK_SYMBOL", "TK_STRING", "TK_CHARACTER", "source",
"single_method", "methods", "@1", "method_list", "method",
"message_pattern", "keyword_list", "temporaries", "variable_list",
"block", "block_var_list", "statements", "expressions", "expression",
"assignments", "assignment", "cascade", "cascade_list", "cascade_item",
"message_expression", "unary_expression", "binary_expression",
"keyword_expression", "keyword_expr_list", "unary_object",
@ -187,14 +190,15 @@ static const char *const yytname[] =
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const short yyr1[] =
{
0, 22, 22, 22, 23, 23, 25, 24, 24, 26,
26, 27, 27, 28, 28, 28, 29, 29, 30, 31,
31, 32, 32, 32, 33, 33, 34, 34, 34, 34,
35, 35, 36, 36, 36, 36, 36, 36, 37, 37,
38, 39, 40, 40, 41, 41, 41, 42, 42, 42,
43, 44, 45, 46, 46, 47, 47, 48, 48, 49,
49, 49, 49, 50, 51, 52, 53, 54, 54, 54,
54, 54, 55, 55, 55, 55, 55, 56, 56, 56
0, 23, 23, 23, 24, 24, 26, 25, 25, 27,
27, 28, 28, 29, 29, 29, 30, 30, 31, 32,
32, 33, 33, 33, 34, 34, 35, 35, 35, 35,
36, 36, 37, 37, 37, 37, 37, 37, 38, 38,
39, 40, 41, 41, 42, 42, 42, 43, 43, 43,
44, 45, 46, 47, 47, 48, 48, 49, 49, 50,
50, 50, 50, 51, 52, 53, 54, 55, 55, 55,
55, 55, 55, 56, 56, 56, 56, 56, 57, 57,
57
};
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
@ -207,7 +211,8 @@ static const short yyr2[] =
2, 2, 2, 3, 1, 2, 1, 1, 1, 1,
2, 3, 2, 2, 3, 1, 1, 1, 1, 1,
1, 1, 3, 1, 1, 1, 1, 1, 1, 1,
1, 3, 0, 1, 1, 2, 2, 1, 1, 1
1, 1, 3, 0, 1, 1, 2, 2, 1, 1,
1
};
/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
@ -215,106 +220,112 @@ static const short yyr2[] =
error. */
static const short yydefact[] =
{
1, 0, 0, 0, 72, 0, 63, 67, 68, 69,
70, 2, 0, 61, 4, 27, 30, 0, 38, 36,
34, 47, 48, 49, 57, 0, 32, 59, 60, 0,
19, 0, 0, 0, 21, 0, 0, 0, 77, 65,
79, 78, 73, 0, 74, 26, 5, 28, 39, 37,
35, 33, 0, 41, 64, 50, 66, 52, 0, 0,
40, 18, 20, 62, 0, 8, 9, 0, 15, 6,
13, 0, 0, 24, 0, 0, 22, 71, 75, 76,
0, 31, 42, 46, 44, 0, 0, 0, 56, 51,
55, 59, 58, 53, 3, 0, 0, 11, 0, 0,
14, 16, 0, 25, 29, 45, 43, 54, 10, 12,
17, 7, 23, 0, 0, 0
1, 0, 0, 0, 73, 0, 63, 67, 68, 69,
70, 71, 2, 0, 61, 4, 27, 30, 0, 38,
36, 34, 47, 48, 49, 57, 0, 32, 59, 60,
0, 19, 0, 0, 0, 21, 0, 0, 0, 78,
65, 80, 79, 74, 0, 75, 26, 5, 28, 39,
37, 35, 33, 0, 41, 64, 50, 66, 52, 0,
0, 40, 18, 20, 62, 0, 8, 9, 0, 15,
6, 13, 0, 0, 24, 0, 0, 22, 72, 76,
77, 0, 31, 42, 46, 44, 0, 0, 0, 56,
51, 55, 59, 58, 53, 3, 0, 0, 11, 0,
0, 14, 16, 0, 25, 29, 45, 43, 54, 10,
12, 17, 7, 23, 0, 0, 0
};
static const short yydefgoto[] =
{
113, 11, 64, 99, 65, 66, 67, 68, 12, 29,
13, 36, 37, 15, 16, 17, 18, 19, 53, 82,
20, 21, 22, 23, 83, 24, 25, 26, 27, 55,
58, 59, 28, 43, 44
114, 12, 65, 100, 66, 67, 68, 69, 13, 30,
14, 37, 38, 16, 17, 18, 19, 20, 54, 83,
21, 22, 23, 24, 84, 25, 26, 27, 28, 56,
59, 60, 29, 44, 45
};
static const short yypact[] =
{
46, 11, 177, 95, 3, 177,-32768,-32768,-32768,-32768,
-32768,-32768, 145,-32768,-32768, -4,-32768, 177,-32768,-32768,
4, 109, 15,-32768, 14, 78, 141, 7,-32768, 64,
-32768, 129, 9, 194,-32768, 11, 29, 27,-32768,-32768,
-32768,-32768,-32768, 184,-32768,-32768,-32768, 161,-32768,-32768,
4, 141, 157, 32,-32768,-32768,-32768, 36, 177, 177,
-32768,-32768,-32768,-32768, 50, 52,-32768, 113, 36, 51,
-32768, 11, 11,-32768, 145, 11,-32768,-32768,-32768,-32768,
177,-32768,-32768, 36,-32768, 177, 157, 177,-32768, 14,
-32768,-32768,-32768, 56,-32768, 157, 145,-32768, 11, 157,
-32768,-32768, 71,-32768,-32768, 14,-32768, 56,-32768,-32768,
-32768, 52,-32768, 82, 85,-32768
116, -4, 203, 97, 3, 203,-32768,-32768,-32768,-32768,
-32768,-32768,-32768, 169,-32768,-32768, 6,-32768, 203,-32768,
-32768, 13, 38, 26,-32768, 15, 29, 51, 9,-32768,
12,-32768, 152, 41, 48,-32768, -4, 28, 47,-32768,
-32768,-32768,-32768,-32768, 219,-32768,-32768,-32768, 186,-32768,
-32768, 13, 51, 112, 44,-32768,-32768,-32768, 52, 203,
203,-32768,-32768,-32768,-32768, 65, 58,-32768, 135, 52,
64,-32768, -4, -4,-32768, 169, -4,-32768,-32768,-32768,
-32768, 203,-32768,-32768, 52,-32768, 203, 112, 203,-32768,
15,-32768,-32768,-32768, 63,-32768, 112, 169,-32768, -4,
112,-32768,-32768, 74,-32768,-32768, 15,-32768, 63,-32768,
-32768,-32768, 58,-32768, 86, 89,-32768
};
static const short yypgoto[] =
{
-32768,-32768,-32768,-32768, -11, -5,-32768,-32768, 33,-32768,
-32768, 69, 2,-32768, 1,-32768, 89, 91,-32768, 25,
101, -50, -49,-32768, 87, -43, -48, -12, -1, -8,
-3, -6, 0,-32768, 77
-32768,-32768,-32768,-32768, -9, 14,-32768,-32768, 24,-32768,
-32768, 61, 2,-32768, 1,-32768, 78, 84,-32768, 21,
95, -52, -55,-32768, 88, -47, -51, -8, -1, -6,
-3, 4, 0,-32768, 77
};
#define YYLAST 211
#define YYLAST 241
static const short yytable[] =
{
30, 41, 14, 32, 42, 51, 45, 47, 88, 88,
92, 93, 60, 4, 46, 89, 63, 52, 38, 39,
40, 7, 8, 9, 10, 70, 6, 72, 62, 54,
71, -58, -58, 74, 73, 88, 76, 88, 92, 107,
41, 75, 105, 78, 84, 86, 90, 90, 81, 85,
1, 87, 2, 56, 3, 95, 4, 91, 91, 94,
5, 6, 98, 75, 7, 8, 9, 10, 61, 97,
100, 101, 39, 90, 103, 90, 102, 87, 84, 6,
112, 104, 114, 85, 91, 115, 91, 70, 111, 72,
108, 70, 71, 72, 39, 56, 71, 110, 109, 33,
96, 2, 69, 31, 34, 4, 48, 35, 49, 5,
6, 106, 57, 7, 8, 9, 10, 1, 50, 2,
79, 31, 0, 4, -56, -56, -56, 5, 6, 0,
0, 7, 8, 9, 10, 2, 0, 31, 34, 4,
0, 35, 0, 5, 6, 0, 0, 7, 8, 9,
10, 2, 0, 31, 0, 4, -55, -55, -55, 5,
6, 0, 0, 7, 8, 9, 10, 2, 0, 31,
0, 4, 54, 39, 56, 80, 6, 0, 0, 7,
8, 9, 10, 2, 0, 31, 0, 4, 0, 0,
0, 77, 6, 0, 4, 7, 8, 9, 10, 38,
39, 40, 7, 8, 9, 10, 35, 0, 0, 54,
39, 56
31, 42, 15, 33, 43, 93, 46, 89, 89, 94,
52, 6, 90, 4, 61, 47, 62, 48, 39, 40,
41, 7, 8, 9, 10, 11, 53, 6, 71, 63,
55, 72, 75, 93, 89, 74, 89, 108, 73, 106,
76, 42, -58, -58, 79, 40, 57, 85, 64, 82,
86, 91, 91, -56, -56, -56, 77, 87, 92, 92,
36, 96, 88, 55, 40, 57, -55, -55, -55, 57,
98, 101, 102, 99, 95, 104, 76, 103, 91, 40,
91, 85, 105, 113, 86, 92, 115, 92, 88, 116,
71, 112, 97, 72, 71, 70, 49, 72, 111, 110,
73, 34, 50, 2, 73, 32, 35, 4, 107, 36,
109, 5, 6, 51, 58, 7, 8, 9, 10, 11,
1, 80, 2, 0, 3, 0, 4, 55, 40, 57,
5, 6, 0, 0, 7, 8, 9, 10, 11, 1,
0, 2, 0, 32, 0, 4, 0, 0, 0, 5,
6, 0, 0, 7, 8, 9, 10, 11, 2, 0,
32, 35, 4, 0, 36, 0, 5, 6, 0, 0,
7, 8, 9, 10, 11, 2, 0, 32, 0, 4,
0, 0, 0, 5, 6, 0, 0, 7, 8, 9,
10, 11, 2, 0, 32, 0, 4, 0, 0, 0,
81, 6, 0, 0, 7, 8, 9, 10, 11, 2,
0, 32, 0, 4, 0, 0, 0, 0, 6, 0,
0, 7, 8, 9, 10, 11, 78, 0, 0, 4,
0, 0, 0, 0, 39, 40, 41, 7, 8, 9,
10, 11
};
static const short yycheck[] =
{
1, 4, 0, 2, 4, 17, 5, 11, 58, 59,
59, 59, 5, 10, 12, 58, 7, 13, 15, 16,
17, 18, 19, 20, 21, 33, 15, 33, 29, 15,
33, 16, 17, 4, 35, 85, 9, 87, 87, 87,
43, 12, 85, 43, 52, 13, 58, 59, 47, 52,
4, 57, 6, 17, 8, 3, 10, 58, 59, 9,
14, 15, 68, 12, 18, 19, 20, 21, 4, 67,
71, 72, 16, 85, 75, 87, 74, 83, 86, 15,
9, 80, 0, 86, 85, 0, 87, 95, 99, 95,
95, 99, 95, 99, 16, 17, 99, 98, 96, 4,
67, 6, 33, 8, 9, 10, 17, 12, 17, 14,
15, 86, 25, 18, 19, 20, 21, 4, 17, 6,
43, 8, -1, 10, 15, 16, 17, 14, 15, -1,
-1, 18, 19, 20, 21, 6, -1, 8, 9, 10,
-1, 12, -1, 14, 15, -1, -1, 18, 19, 20,
21, 6, -1, 8, -1, 10, 15, 16, 17, 14,
15, -1, -1, 18, 19, 20, 21, 6, -1, 8,
-1, 10, 15, 16, 17, 14, 15, -1, -1, 18,
19, 20, 21, 6, -1, 8, -1, 10, -1, -1,
-1, 7, 15, -1, 10, 18, 19, 20, 21, 15,
16, 17, 18, 19, 20, 21, 12, -1, -1, 15,
16, 17
1, 4, 0, 2, 4, 60, 5, 59, 60, 60,
18, 15, 59, 10, 5, 13, 4, 11, 15, 16,
17, 18, 19, 20, 21, 22, 13, 15, 34, 30,
15, 34, 4, 88, 86, 36, 88, 88, 34, 86,
12, 44, 16, 17, 44, 16, 17, 53, 7, 48,
53, 59, 60, 15, 16, 17, 9, 13, 59, 60,
12, 3, 58, 15, 16, 17, 15, 16, 17, 17,
68, 72, 73, 69, 9, 76, 12, 75, 86, 16,
88, 87, 81, 9, 87, 86, 0, 88, 84, 0,
96, 100, 68, 96, 100, 34, 18, 100, 99, 97,
96, 4, 18, 6, 100, 8, 9, 10, 87, 12,
96, 14, 15, 18, 26, 18, 19, 20, 21, 22,
4, 44, 6, -1, 8, -1, 10, 15, 16, 17,
14, 15, -1, -1, 18, 19, 20, 21, 22, 4,
-1, 6, -1, 8, -1, 10, -1, -1, -1, 14,
15, -1, -1, 18, 19, 20, 21, 22, 6, -1,
8, 9, 10, -1, 12, -1, 14, 15, -1, -1,
18, 19, 20, 21, 22, 6, -1, 8, -1, 10,
-1, -1, -1, 14, 15, -1, -1, 18, 19, 20,
21, 22, 6, -1, 8, -1, 10, -1, -1, -1,
14, 15, -1, -1, 18, 19, 20, 21, 22, 6,
-1, 8, -1, 10, -1, -1, -1, -1, 15, -1,
-1, 18, 19, 20, 21, 22, 7, -1, -1, 10,
-1, -1, -1, -1, 15, 16, 17, 18, 19, 20,
21, 22
};
#define YYPURE 1
@ -1356,57 +1367,61 @@ case 62:
;
break;}
case 67:
#line 372 "STGrammar.y"
{ yyval = [COMPILER createNumberLiteralFrom:yyvsp[0]]; ;
#line 373 "STGrammar.y"
{ yyval = [COMPILER createIntNumberLiteralFrom:yyvsp[0]]; ;
break;}
case 68:
#line 374 "STGrammar.y"
{ yyval = [COMPILER createSymbolLiteralFrom:yyvsp[0]]; ;
#line 375 "STGrammar.y"
{ yyval = [COMPILER createRealNumberLiteralFrom:yyvsp[0]]; ;
break;}
case 69:
#line 376 "STGrammar.y"
{ yyval = [COMPILER createStringLiteralFrom:yyvsp[0]]; ;
#line 377 "STGrammar.y"
{ yyval = [COMPILER createSymbolLiteralFrom:yyvsp[0]]; ;
break;}
case 70:
#line 378 "STGrammar.y"
{ yyval = [COMPILER createCharacterLiteralFrom:yyvsp[0]]; ;
#line 379 "STGrammar.y"
{ yyval = [COMPILER createStringLiteralFrom:yyvsp[0]]; ;
break;}
case 71:
#line 380 "STGrammar.y"
{ yyval = [COMPILER createArrayLiteralFrom:yyvsp[-1]]; ;
#line 381 "STGrammar.y"
{ yyval = [COMPILER createCharacterLiteralFrom:yyvsp[0]]; ;
break;}
case 72:
#line 382 "STGrammar.y"
{ yyval = [NSMutableArray array]; ;
#line 383 "STGrammar.y"
{ yyval = [COMPILER createArrayLiteralFrom:yyvsp[-1]]; ;
break;}
case 73:
#line 383 "STGrammar.y"
#line 385 "STGrammar.y"
{ yyval = [NSMutableArray array]; ;
break;}
case 74:
#line 386 "STGrammar.y"
{ yyval = [NSMutableArray array];
[yyval addObject:yyvsp[0]]; ;
break;}
case 74:
#line 385 "STGrammar.y"
case 75:
#line 388 "STGrammar.y"
{ yyval = [NSMutableArray array];
[yyval addObject:yyvsp[0]]; ;
break;}
case 75:
#line 387 "STGrammar.y"
{ yyval = yyvsp[-1]; [yyval addObject:yyvsp[0]]; ;
break;}
case 76:
#line 388 "STGrammar.y"
#line 390 "STGrammar.y"
{ yyval = yyvsp[-1]; [yyval addObject:yyvsp[0]]; ;
break;}
case 77:
#line 391 "STGrammar.y"
{ yyval = [COMPILER createSymbolLiteralFrom:yyvsp[0]]; ;
{ yyval = yyvsp[-1]; [yyval addObject:yyvsp[0]]; ;
break;}
case 78:
#line 393 "STGrammar.y"
#line 394 "STGrammar.y"
{ yyval = [COMPILER createSymbolLiteralFrom:yyvsp[0]]; ;
break;}
case 79:
#line 395 "STGrammar.y"
#line 396 "STGrammar.y"
{ yyval = [COMPILER createSymbolLiteralFrom:yyvsp[0]]; ;
break;}
case 80:
#line 398 "STGrammar.y"
{ yyval = [COMPILER createSymbolLiteralFrom:yyvsp[0]]; ;
break;}
}
@ -1642,7 +1657,7 @@ yyreturn:
#endif
return yyresult;
}
#line 397 "STGrammar.y"
#line 400 "STGrammar.y"
int STCerror(const char *str)
@ -1689,7 +1704,8 @@ int STClex (YYSTYPE *lvalp, void *context)
case STSymbolTokenType: return TK_SYMBOL;
case STStringTokenType: return TK_STRING;
case STCharacterTokenType: return TK_CHARACTER;
case STNumberTokenType: return TK_NUMBER;
case STIntNumberTokenType: return TK_INTNUMBER;
case STRealNumberTokenType: return TK_REALNUMBER;
case STSeparatorTokenType: return TK_SEPARATOR;
case STEndTokenType: return 0;

View file

@ -58,7 +58,7 @@
%token TK_LPAREN TK_RPAREN TK_BLOCK_OPEN TK_BLOCK_CLOSE TK_ARRAY_OPEN
%token TK_DOT TK_COLON TK_SEMICOLON TK_RETURN
%token TK_IDENTIFIER TK_BINARY_SELECTOR TK_KEYWORD
%token TK_NUMBER TK_SYMBOL TK_STRING TK_CHARACTER
%token TK_INTNUMBER TK_REALNUMBER TK_SYMBOL TK_STRING TK_CHARACTER
/* Grammar */
@ -368,8 +368,11 @@ binary_selector: TK_BINARY_SELECTOR
;
keyword: TK_KEYWORD
;
literal: TK_NUMBER
{ $$ = [COMPILER createNumberLiteralFrom:$1]; }
literal:
TK_INTNUMBER
{ $$ = [COMPILER createIntNumberLiteralFrom:$1]; }
| TK_REALNUMBER
{ $$ = [COMPILER createRealNumberLiteralFrom:$1]; }
| TK_SYMBOL
{ $$ = [COMPILER createSymbolLiteralFrom:$1]; }
| TK_STRING
@ -440,7 +443,8 @@ int STClex (YYSTYPE *lvalp, void *context)
case STSymbolTokenType: return TK_SYMBOL;
case STStringTokenType: return TK_STRING;
case STCharacterTokenType: return TK_CHARACTER;
case STNumberTokenType: return TK_NUMBER;
case STIntNumberTokenType: return TK_INTNUMBER;
case STRealNumberTokenType: return TK_REALNUMBER;
case STSeparatorTokenType: return TK_SEPARATOR;
case STEndTokenType: return 0;

View file

@ -283,10 +283,12 @@ static NSString *_STNormalizeStringToken(NSString *token)
tokenRange = NSMakeRange(start,srcOffset - start);
return STIdentifierTokenType;
}
else if ( c == '-' || [numericCharacterSet characterIsMember:c])
else if ( c == '-' || c == '+' || [numericCharacterSet characterIsMember:c])
{
BOOL maybesym = (c == '-');
BOOL maybesym = (c == '-' || c == '+');
BOOL scannedSomething = NO;
BOOL isReal = NO;
start = srcOffset++;
c = GET_CHAR;
@ -311,10 +313,57 @@ static NSString *_STNormalizeStringToken(NSString *token)
if(AT_END)
break;
}
if(c == '.')
{
c = GET_CHAR;
while([numericCharacterSet characterIsMember:c])
{
c = GET_CHAR;
scannedSomething = YES;
if(AT_END)
break;
}
if(!scannedSomething)
{
tokenRange = NSMakeRange(start,srcOffset - start + 1);
[NSException raise:STCompilerSyntaxException
format:@"Expected digit after the decimal point"];
return STErrorTokenType;
}
scannedSomething = NO;
isReal = YES;
}
if(c == 'e' || c == 'E')
{
c = GET_CHAR;
if(c == '+' || c == '-')
{
c = GET_CHAR;
}
while([numericCharacterSet characterIsMember:c])
{
c = GET_CHAR;
scannedSomething = YES;
if(AT_END)
break;
}
if(!scannedSomething)
{
tokenRange = NSMakeRange(start,srcOffset - start + 1);
[NSException raise:STCompilerSyntaxException
format:@"Expected digits in the exponent"];
return STErrorTokenType;
}
scannedSomething = NO;
isReal = YES;
}
srcOffset --;
tokenRange = NSMakeRange(start,srcOffset - start);
if([identStartCharacterSet characterIsMember:c])
if([identStartCharacterSet characterIsMember:c] && c != 'e' && c != 'E')
{
tokenRange = NSMakeRange(start,srcOffset - start + 1);
[NSException raise:STCompilerSyntaxException
@ -322,7 +371,14 @@ static NSString *_STNormalizeStringToken(NSString *token)
return STErrorTokenType;
}
return STNumberTokenType;
if(isReal)
{
return STRealNumberTokenType;
}
else
{
return STIntNumberTokenType;
}
}
else if ([symbolicSelectorCharacterSet characterIsMember:c])

View file

@ -47,7 +47,8 @@ typedef enum
STStringTokenType, // 'This is string'
STCharacterTokenType, // $a (any single alphanum character)
STNumberTokenType, // -?[0-9]+
STIntNumberTokenType, // [+-]?[0-9]+
STRealNumberTokenType, // [+-]?[0-9]+.[0-9]+[eE][+-][0-9]+
STEndTokenType

View file

@ -22,8 +22,6 @@
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
#
GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_USER_ROOT)
GNUSTEP_MAKEFILES = $(GNUSTEP_SYSTEM_ROOT)/Makefiles
include $(GNUSTEP_MAKEFILES)/common.make

19
NEWS
View file

@ -1,3 +1,22 @@
0.6.2
* Smalltalk: Added parsing of real numbers
* ObjectiveC: added two new methods into the Runtime object:
selectorsContainingString:
returns an array of selectors that contain specified string
implementorsOfSelector:
returns an array of all classes that implement specified selector
* Created an empty language bundle MyLanguage as an example
* Added GDL2 module
* Fixed installation: removed forced installation to the user's home
directory
NOTE: Please delete all standard StepTalk language bundles, modules and
finders from your home directory if it is not your default installation
directory so new bundles can be found.
0.6.1
* Code cleanup

View file

@ -5,4 +5,19 @@
extern := nil.
extern := nil.
extern := nil.
extern := nil.
extern := nil.
extern := nil.
extern := nil.
extern := nil.
extern := nil.
extern := nil.
extern := nil.
extern := nil.
extern := nil.
extern := nil.
extern := nil.
extern := nil.
extern := nil.
extern := nil.
]

View file

@ -7,4 +7,19 @@
local := nil.
local := nil.
local := nil.
local := nil.
local := nil.
local := nil.
local := nil.
local := nil.
local := nil.
local := nil.
local := nil.
local := nil.
local := nil.
local := nil.
local := nil.
local := nil.
local := nil.
local := nil.
]