diff options
author | Nadia Polikarpova <nadia.polikarpova@gmail.com> | 2013-07-31 15:02:05 +0200 |
---|---|---|
committer | Nadia Polikarpova <nadia.polikarpova@gmail.com> | 2013-07-31 15:02:05 +0200 |
commit | efcbed91308c9f585a6e5c8fc807e069d291ed0c (patch) | |
tree | 7aec43d69ab45e8208e6f0f304a12b1d69bf566c /Source/Dafny/Dafny.atg | |
parent | 6c7d4a409f3ced78bd1d15c9743bb357c46320fa (diff) | |
parent | d73eb5ccdcb87f98edf0769b2deed0e87f62f545 (diff) |
Merge
Diffstat (limited to 'Source/Dafny/Dafny.atg')
-rw-r--r-- | Source/Dafny/Dafny.atg | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/Source/Dafny/Dafny.atg b/Source/Dafny/Dafny.atg index f9dff93f..778e2f72 100644 --- a/Source/Dafny/Dafny.atg +++ b/Source/Dafny/Dafny.atg @@ -122,6 +122,7 @@ CHARACTERS letter = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".
digit = "0123456789".
posDigit = "123456789".
+ hexdigit = "0123456789ABCDEFabcdef".
special = "'_?\\".
glyph = "`~!@#$%^&*()-_=+[{]}|;:',<.>/?\\".
cr = '\r'.
@@ -149,6 +150,7 @@ TOKENS | 'a' 'r' 'r' 'a' 'y' idcharMinusPosDigit {idchar}
| 'a' 'r' 'r' 'a' 'y' posDigit {idchar} nondigit {idchar}.
digits = digit {digit}.
+ hexdigits = '0' 'x' hexdigit {hexdigit}.
arrayToken = 'a' 'r' 'r' 'a' 'y' [posDigit {digit}].
string = quote {nonquote} quote.
colon = ':'.
@@ -2088,14 +2090,24 @@ WildIdent<out IToken/*!*/ x, bool allowWildcardId> .
Nat<out BigInteger n>
-=
- digits
- (. try {
- n = BigInteger.Parse(t.val);
- } catch (System.FormatException) {
- SemErr("incorrectly formatted number");
- n = BigInteger.Zero;
- }
- .)
+= (. n = BigInteger.Zero; .)
+ (digits
+ (. try {
+ n = BigInteger.Parse(t.val);
+ } catch (System.FormatException) {
+ SemErr("incorrectly formatted number");
+ n = BigInteger.Zero;
+ }
+ .)
+ |hexdigits
+ (. try {
+ // note: leading 0 required when parsing positive hex numbers
+ n = BigInteger.Parse("0" + t.val.Substring(2), System.Globalization.NumberStyles.HexNumber);
+ } catch (System.FormatException) {
+ SemErr("incorrectly formatted number");
+ n = BigInteger.Zero;
+ }
+ .)
+ )
.
END Dafny.
|