// Mono.MonoBASIC.Tokenizer.cs: The Tokenizer for the MonoBASIC compiler
//
// Author: A Rafael D Teixeira (rafaelteixeirabr@hotmail.com)
-//
+// : Manjula GHM (mmanjula@novell.com)
// Based on cs-tokenizer.cs by Miguel de Icaza (miguel@gnu.org)
//
// Licensed under the terms of the GNU GPL
StringBuilder number;
int putback_char = -1;
Object val;
+ long lon = 0;
//
// Details about the error encoutered by the tokenizer
keywords.Add ("is", Token.IS);
keywords.Add ("let ", Token.LET ); // An unused VB.NET keyword
keywords.Add ("lib ", Token.LIB );
- keywords.Add ("like ", Token.LIKE );
+ keywords.Add ("like", Token.LIKE );
keywords.Add ("long", Token.LONG);
keywords.Add ("loop", Token.LOOP);
keywords.Add ("me", Token.ME);
if (c != -1)
number.Append ((char) c);
-
while ((d = peekChar ()) != -1){
if (Char.IsDigit ((char)d)){
number.Append ((char) d);
switch (c){
case 'S': case 's':
t = Token.LITERAL_INTEGER; // SHORT ?
- val = ((IConvertible)val).ToInt16(null);
+
+ // hexadecimal literals - like &H8000S is "-32768"
+ // and not an overflow exception
+ // Check for other literals ???
+
+ if(lon == 32768) {
+ val = (short) lon;
+ }
+ else
+ val = ((IConvertible)val).ToInt16(null);
break;
case 'I': case 'i':
t = Token.LITERAL_INTEGER;
} else
break;
}
- return System.Int64.Parse (hexNumber.ToString(), NumberStyles.HexNumber);
+ lon = System.Int64.Parse (hexNumber.ToString(), NumberStyles.HexNumber);
+ return lon;
}
long octal_digits ()
bool is_real = false;
number = new StringBuilder ();
int type;
+ bool non_prefixdecimal = false; //To capture decimals like .50
number.Length = 0;
if (Char.IsDigit ((char)c)){
decimal_digits (c);
- c = peekChar ();
+ c = peekChar ();
+ non_prefixdecimal = true;
}
//
// "1.1" vs "1.ToString()" (LITERAL_SINGLE vs NUMBER DOT IDENTIFIER)
//
if (c == '.'){
+ if (non_prefixdecimal == false)
+ putback ('.');
if (decimal_digits (getChar())){
is_real = true;
c = peekChar ();
return putback_char;
return reader.Peek ();
}
+
void putback (int c)
{
private int DropComments()
{
- int d;
- while (!IsEOL(d = getChar ()))
+ //int d;
+ while (!IsEOL(/*d =*/ getChar ()))
col++;
return Token.EOL;
}
+
+ public bool putbacktoken = false;
+ public bool flag = false;
+ int next_token;
public int token ()
{
do
{
current_token = xtoken ();
+ if(current_token == Token.END) {
+ next_token = xtoken();
+ putbacktoken = true;
+ if (next_token == Token.EOL)
+ return Token.END_EOL;
+ else
+ return Token.END;
+ }
if (current_token == 0)
return Token.EOF;
if (current_token == Token.REM)
bool doread = false;
int c;
+ if (putbacktoken == true) {
+ putbacktoken = false;
+ return next_token;
+ }
+
val = null;
for (;(c = getChar ()) != -1; col++) {
c = getChar ();
}
}
-
+
+
// white space
if (is_whitespace(c)) {
// expand tabs for location
}
// handle numeric literals
+
+ if (Char.IsDigit ((char) c))
+ {
+ cant_have_a_type_character = true;
+ tokens_seen = true;
+ return is_number (c);
+ }
+
if (c == '.')
{
cant_have_a_type_character = true;
return is_number (c);
return Token.DOT;
}
-
- if (Char.IsDigit ((char) c))
- {
- cant_have_a_type_character = true;
- tokens_seen = true;
- return is_number (c);
- }
-
if ((t = is_punct ((char)c, ref doread)) != Token.ERROR) {
cant_have_a_type_character = true;
{
int t;
- for(t = token(); t != Token.HASH && t != Token.EOF; t = token());
+ for(t = token(); t != Token.HASH && t != Token.EOF ; t = token());
if(t == Token.EOF)
throw new ApplicationException("Unexpected EOF while looking for a pre-processor directive");