Commit e0719624 authored by Benoit Perrot's avatar Benoit Perrot
Browse files

Index: ChangeLog

from  Benoît Perrot  <benoit@lrde.epita.fr>

	Strengthen lexical analysis.
	
	* dev/parse-asm-scan-gen.py: Complain when a lexicaly correct
	integer cannot be converted by istringstream, for example when the
	said integer is too large. For hexadecimal integers, a maximal
	number of digits might be used, but it seems more generic to
	handle it through istringstream; never knowns, someday nolimips
	may have to support 64 or event 128 bits long integers :). Call
	step() each time an invalid character is detected, to have a more
	clever error message. Step only one line when an eol sequence is
	detected.
	* tests/lexical/invalid-characters.s, integer-too-large.s: New.
	* tests/lexical/Makefile.am: Update accordingly.
parent dac5b64f
2004-01-04 Benot Perrot <benoit@lrde.epita.fr>
Strengthen lexical analysis.
* dev/parse-asm-scan-gen.py: Complain when a lexicaly correct
integer cannot be converted by istringstream, for example when the
said integer is too large. For hexadecimal integers, a maximal
number of digits might be used, but it seems more generic to
handle it through istringstream; never knowns, someday nolimips
may have to support 64 or event 128 bits long integers :). Call
step() each time an invalid character is detected, to have a more
clever error message. Step only one line when an eol sequence is
detected.
* tests/lexical/invalid-characters.s, integer-too-large.s: New.
* tests/lexical/Makefile.am: Update accordingly.
2004-12-18 Benot Perrot <benoit@lrde.epita.fr>
Kill (some) autotools warnings. Some m4 files from GNUlib still use
......
......@@ -88,7 +88,7 @@ label [a-zA-Z_][a-zA-Z_0-9]*
[ \\t]+ yylloc->step ();
[#;][^\\n\\r]* yylloc->step ();
{eol} yylloc->lines (yyleng); yylloc->step ();
{eol} yylloc->lines (1); yylloc->step ();
\"(\" return LPAREN;
\")\" return RPAREN;
......@@ -164,9 +164,28 @@ print """
}
-?{dec_int} yylval->i = atoi (yytext); return INTEGER;
-?{dec_int} {
std::istringstream iss(yytext);
iss >> std::dec >> (unsigned&) yylval->i;
if (iss.fail())
{
std::cerr << *yylloc
<< \": unrecognized integer (may be too large): \"
<< yytext << std::endl;
exit_set (exit_scan);
}
return INTEGER;
}
-?{hex_int} {
std::istringstream(yytext) >> std::hex >> (unsigned&) yylval->i;
std::istringstream iss(yytext);
iss >> std::hex >> (unsigned&) yylval->i;
if (iss.fail())
{
std::cerr << *yylloc
<< \": unrecognized integer (may be too large): \"
<< yytext << std::endl;
exit_set (exit_scan);
}
return INTEGER;
}
......@@ -225,9 +244,9 @@ print """
[^\\\"\\n\\r\\\\]+ yylval->s->append (yytext, yyleng);
{eol}+ {
yylloc->lines (yyleng);
yylval->s->append (yyleng, '\\n');
{eol} {
yylloc->lines (1);
yylval->s->append (yytext, yyleng);
}
<<EOF>> {
......@@ -244,6 +263,7 @@ print """
std::cerr << *yylloc
<< \": invalid character: `\"
<< escape (yytext) << \"'\" << std::endl;
yylloc->step ();
exit_set (exit_scan);
}
......
### Sources
ASM_FILES = \
invalid-characters.s \
invalid-string-octal.s \
invalid-string-hexa.s \
unrecognized-escape.s \
unterminated-string.s
unterminated-string.s \
integer-too-large.s
dist_noinst_DATA = $(ASM_FILES)
......
.text
main:
li $v0, 0xffffffffffffffff
li $v0, 123456789123456789
li $a0, 0
li $v0, 10
syscall
.text
label:
subu $sp,$sp,32
sw $31,28($sp)
sw $fp,24($sp)
move $fp,$sp
sw $4,32($fp)
lw $2,32($fp)
slt $2,$2,2
beq $2,$0,L2
li $2,1 # 0x1 @
sw $2,16($fp)
j label
@
li $a0, 0
li $v0, 10
syscall
# ``
~
``
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment