[Mono-list] [PATCH] String literals
Andrew Birkett
adb@tardis.ed.ac.uk
Fri, 5 Jul 2002 18:16:43 +0100 (BST)
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to mime@docserver.cac.washington.edu for more info.
---559023410-851401618-1025889403=:10286
Content-Type: TEXT/PLAIN; charset=US-ASCII
Hi,
This patch does the following:
- makes mcs reject newlines in (non-verbatim) string literals
- Ensures that '@' is followed immediately by a string or an identifier
- Reports an error when EOF is found in a string constant.
- Adds a new test to tests/test-74.cs
The attached patch applies correctly on cygwin and solaris, so hopefully
no cr/lf woes. I've also included a tarball with three new files for
mcs/errors which check for the above errors. Hmm, but no changelog entry
in there yet.
I can commit these to CVS myself if you want.
Andrew
- www.tardis.ed.ac.uk/~adb -
---559023410-851401618-1025889403=:10286
Content-Type: TEXT/PLAIN; charset=US-ASCII; name=string-lit-patch
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.GS4.4.33.0207051816430.10286@davros.tardis.ed.ac.uk>
Content-Description: Patch for mcs/cs-tokenizer.cs for string lits
Content-Disposition: attachment; filename=string-lit-patch
SW5kZXg6IG1jcy9jcy10b2tlbml6ZXIuY3MNCj09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT0NClJDUyBmaWxlOiAvbW9uby9tY3MvbWNzL2NzLXRva2VuaXplci5j
cyx2DQpyZXRyaWV2aW5nIHJldmlzaW9uIDEuNTcNCmRpZmYgLXUgLXIxLjU3
IGNzLXRva2VuaXplci5jcw0KLS0tIG1jcy9jcy10b2tlbml6ZXIuY3MJNCBK
dWwgMjAwMiAxODoyMDoxMCAtMDAwMAkxLjU3DQorKysgbWNzL2NzLXRva2Vu
aXplci5jcwk1IEp1bCAyMDAyIDE2OjQ4OjI4IC0wMDAwDQpAQCAtMTAzNCwx
MyArMTAzNCwxMyBAQA0KIAkJCQkJcmV0dXJuIGZhbHNlOw0NCiAJCQkJf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09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09DQpSQ1MgZmlsZTogL21vbm8v
bWNzL3Rlc3RzL3Rlc3QtNzQuY3Msdg0KcmV0cmlldmluZyByZXZpc2lvbiAx
LjINCmRpZmYgLXUgLXIxLjIgdGVzdC03NC5jcw0KLS0tIHRlc3RzL3Rlc3Qt
NzQuY3MJMjUgRmViIDIwMDIgMjA6MTc6MDAgLTAwMDAJMS4yDQorKysgdGVz
dHMvdGVzdC03NC5jcwk1IEp1bCAyMDAyIDE2OjQ4OjI4IC0wMDAwDQpAQCAt
MTcsNiArMTcsMTMgQEANCiAJCQlyZXR1cm4gMTsNCiAJCWlmIChlICE9IGYp
DQogCQkJcmV0dXJuIDI7DQorDQorCQlzdHJpbmcgZyA9ICJIZWxsb1xud29y
bGQiOw0KKwkJc3RyaW5nIGggPSBAIkhlbGxvDQord29ybGQiOw0KKwkJaWYg
KGcgIT0gaCkgDQorCQkJcmV0dXJuIDM7DQorDQogCQlyZXR1cm4gMDsNCiAJ
fQ0KIH0NCg==
---559023410-851401618-1025889403=:10286
Content-Type: APPLICATION/octet-stream; name="string-lit-newfiles.tgz"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.GS4.4.33.0207051816431.10286@davros.tardis.ed.ac.uk>
Content-Description: New tests for mcs/errors for string literal handling
Content-Disposition: attachment; filename="string-lit-newfiles.tgz"
H4sIAAAAAAAAC+3WQUvDMBjG8V4N5Du87qQX27Rdh4gwb552E7x2bToCXQJJ
pIj43X23iRNRcIe1l+d3KQ2hNIF/Wu298yFtgspUdtOE5Az4yVlVlknGFtX+
yiNqf7+jFI8t5koVuZoXFc8vVZ4nlJ3jZX56CbH2RMlDuzXWhOjr6Pwv81bO
6jHeZ2RpSis99MZqMpYaZ3k7bJRCiqavQ6BnKd6kuODRaBri7TF2Q4Huafao
+95JMTjft5ezOynep14LnE4f+y+KqfrPj/0vCnXof47+x8D9L2nLm0BrTZ3j
pAfd0vqVZnTlPJlW22g6o/3114lAfx0JS9qdAlJMvSb4v+/9307Vf1Yd+68O
3/+yQP9j4P6fbNSeF19HLv8z51N+BDrnpl4FAAAAAAAAAAAAAAAAAAB8AAKj
rXkAKAAA
---559023410-851401618-1025889403=:10286--