>From 0cca1c1099dd31bca3cc801824891879f50ca8d1 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sat, 14 Aug 2010 10:37:36 +0800 Subject: [PATCH 2/2] Allow to have "arbitary" length for binarySelectors --- libgst/lex.c | 24 ++++++++++++++++++++---- packages/stinst/parser/RBParser.st | 4 ++++ packages/stinst/parser/SqueakParser.st | 4 ++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/libgst/lex.c b/libgst/lex.c index ded3907..cac6efd 100644 --- a/libgst/lex.c +++ b/libgst/lex.c @@ -615,17 +615,17 @@ scan_bin_op_1 (int c, YYSTYPE *lvalp, mst_Boolean maybe_number) { - char buf[3]; - int ic; + char buf[10]; + int ic, i; buf[0] = c; ic = _gst_next_char (); if (ic != EOF && (CHAR_TAB (ic)->char_class & BIN_OP_CHAR)) { - buf[1] = ic, buf[2] = 0; /* temptatively accumulate next char */ + buf[1] = ic; /* temptatively accumulate next char */ - /* This may be a two-character binary operator, except if + /* This may be a n-character binary operator, except if the second character is a - and is followed by a digit. */ if (ic == '-') { @@ -637,6 +637,22 @@ scan_bin_op_1 (int c, buf[1] = '\0'; } } + else + { + /* scan up to eight more chars.. */ + for (i = 2; i < sizeof(buf)/sizeof(buf[0]) - 1; ++i) + { + ic = _gst_next_char (); + if (ic != EOF && (CHAR_TAB (ic)->char_class & BIN_OP_CHAR)) + buf[i] = ic; + else + { + _gst_unread_char (ic); + break; + } + } + buf[i] = '\0'; + } } else { diff --git a/packages/stinst/parser/RBParser.st b/packages/stinst/parser/RBParser.st index f40356b..66f2479 100644 --- a/packages/stinst/parser/RBParser.st +++ b/packages/stinst/parser/RBParser.st @@ -1127,6 +1127,10 @@ Stream subclass: RBScanner [ ifTrue: [buffer nextPut: currentCharacter. self step]. + [characterType == #binary] + whileTrue: [ + buffer nextPut: currentCharacter. + self step]. val := buffer contents. val := val asSymbol. ^aClass value: val start: tokenStart diff --git a/packages/stinst/parser/SqueakParser.st b/packages/stinst/parser/SqueakParser.st index a5f79b3..8c2cb7a 100644 --- a/packages/stinst/parser/SqueakParser.st +++ b/packages/stinst/parser/SqueakParser.st @@ -133,6 +133,10 @@ STFileScanner subclass: SqueakFileInScanner [ ifFalse: [buffer nextPut: currentCharacter. self step]]. + [characterType == #binary] + whileTrue: [ + buffer nextPut: currentCharacter. + self step]. val := buffer contents. val := val asSymbol. -- 1.7.2.1