summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xcompiler/lexer.nim9
-rwxr-xr-xdoc/grammar.txt1
-rwxr-xr-xdoc/manual.txt51
-rwxr-xr-xlib/system.nim4
-rwxr-xr-xtodo.txt3
-rwxr-xr-xweb/news.txt1
6 files changed, 52 insertions, 17 deletions
diff --git a/compiler/lexer.nim b/compiler/lexer.nim
index afa52d621..01d284692 100755
--- a/compiler/lexer.nim
+++ b/compiler/lexer.nim
@@ -266,7 +266,10 @@ proc GetNumber(L: var TLexer): TToken =
   result.literal = ""
   result.base = base10        # BUGFIX
   pos = L.bufpos     # make sure the literal is correct for error messages:
-  matchUnderscoreChars(L, result, {'A'..'Z', 'a'..'z', '0'..'9'})
+  if L.buf[pos] == '0' and L.buf[pos+1] in {'X', 'x'}:
+    matchUnderscoreChars(L, result, {'A'..'F', 'a'..'f', '0'..'9', 'X', 'x'})
+  else:
+    matchUnderscoreChars(L, result, {'0'..'9', 'b', 'B', 'o', 'c', 'C'})
   if (L.buf[L.bufpos] == '.') and (L.buf[L.bufpos + 1] in {'0'..'9'}): 
     add(result.literal, '.')
     inc(L.bufpos) 
@@ -280,9 +283,9 @@ proc GetNumber(L: var TLexer): TToken =
         inc(L.bufpos)
       matchUnderscoreChars(L, result, {'0'..'9'})
   endpos = L.bufpos
-  if L.buf[endpos] == '\'':
+  if L.buf[endpos] in {'\'', 'f', 'F', 'i', 'I', 'u', 'U'}:
     #matchUnderscoreChars(L, result, ['''', 'f', 'F', 'i', 'I', '0'..'9']);
-    inc(endpos)
+    if L.buf[endpos] == '\'': inc(endpos)
     L.bufpos = pos            # restore position
     case L.buf[endpos]
     of 'f', 'F': 
diff --git a/doc/grammar.txt b/doc/grammar.txt
index 8a39c5abc..4dcb2d3f8 100755
--- a/doc/grammar.txt
+++ b/doc/grammar.txt
@@ -42,6 +42,7 @@ primary ::= primaryPrefix* (symbol [generalizedLit] |
 generalizedLit ::= GENERALIZED_STR_LIT | GENERALIZED_TRIPLESTR_LIT
 
 literal ::= INT_LIT | INT8_LIT | INT16_LIT | INT32_LIT | INT64_LIT
+          | UINT_LIT | UINT8_LIT | UINT16_LIT | UINT32_LIT | UINT64_LIT
           | FLOAT_LIT | FLOAT32_LIT | FLOAT64_LIT
           | STR_LIT | RSTR_LIT | TRIPLESTR_LIT
           | CHAR_LIT
diff --git a/doc/manual.txt b/doc/manual.txt
index 8f9186ec6..df34986ce 100755
--- a/doc/manual.txt
+++ b/doc/manual.txt
@@ -303,20 +303,33 @@ Numerical constants
   hexdigit ::= digit | 'A'..'F' | 'a'..'f'

   octdigit ::= '0'..'7'

   bindigit ::= '0'..'1'

-  INT_LIT ::= digit ( ['_'] digit )*

-            | '0' ('x' | 'X' ) hexdigit ( ['_'] hexdigit )*

-            | '0o' octdigit ( ['_'] octdigit )*

-            | '0' ('b' | 'B' ) bindigit ( ['_'] bindigit )*

-

-  INT8_LIT ::= INT_LIT '\'' ('i' | 'I' ) '8'

-  INT16_LIT ::= INT_LIT '\'' ('i' | 'I' ) '16'

-  INT32_LIT ::= INT_LIT '\'' ('i' | 'I' ) '32'

-  INT64_LIT ::= INT_LIT '\'' ('i' | 'I' ) '64'

+  HEX_LIT ::= '0' ('x' | 'X' ) hexdigit ( ['_'] hexdigit )*
+  DEC_LIT ::= digit ( ['_'] digit )*
+  OCT_LIT ::= '0o' octdigit ( ['_'] octdigit )*
+  BIN_LIT ::= '0' ('b' | 'B' ) bindigit ( ['_'] bindigit )*
+  
+  INT_LIT ::= HEX_LIT

+            | DEC_LIT

+            | OCT_LIT

+            | BIN_LIT
+

+  INT8_LIT ::= INT_LIT ['\''] ('i' | 'I') '8'
+  INT16_LIT ::= INT_LIT ['\''] ('i' | 'I') '16'
+  INT32_LIT ::= INT_LIT ['\''] ('i' | 'I') '32'
+  INT64_LIT ::= INT_LIT ['\''] ('i' | 'I') '64'
+
+  UINT8_LIT ::= INT_LIT ['\''] ('u' | 'U')
+  UINT8_LIT ::= INT_LIT ['\''] ('u' | 'U') '8'
+  UINT16_LIT ::= INT_LIT ['\''] ('u' | 'U') '16'
+  UINT32_LIT ::= INT_LIT ['\''] ('u' | 'U') '32'
+  UINT64_LIT ::= INT_LIT ['\''] ('u' | 'U') '64'
 

   exponent ::= ('e' | 'E' ) ['+' | '-'] digit ( ['_'] digit )*

   FLOAT_LIT ::= digit (['_'] digit)*  ('.' (['_'] digit)* [exponent] |exponent)

-  FLOAT32_LIT ::= ( FLOAT_LIT | INT_LIT ) '\'' ('f' | 'F') '32'

-  FLOAT64_LIT ::= ( FLOAT_LIT | INT_LIT ) '\'' ('f' | 'F') '64'

+  FLOAT32_LIT ::= HEX_LIT '\'' ('f'|'F') '32'
+             | (FLOAT_LIT | DEC_LIT | OCT_LIT | BIN_LIT) ['\''] ('f'|'F') '32'
+  FLOAT64_LIT ::= HEX_LIT '\'' ('f'|'F') '64'
+             | (FLOAT_LIT | DEC_LIT | OCT_LIT | BIN_LIT) ['\''] ('f'|'F') '64'
 

 

 As can be seen in the productions, numerical constants can contain underscores

@@ -328,7 +341,10 @@ There exists a literal for each numerical type that is
 defined. The suffix starting with an apostrophe ('\'') is called a

 `type suffix`:idx:. Literals without a type suffix are of the type ``int``,

 unless the literal contains a dot or ``E|e`` in which case it is of

-type ``float``.

+type ``float``. For notational convenience the apostrophe of a type suffix
+is optional if it is not ambiguous (only hexadecimal floating point literals
+can be ambiguous).
+

 

 The type suffixes are:

 

@@ -338,7 +354,12 @@ The type suffixes are:
   ``'i8``            int8

   ``'i16``           int16

   ``'i32``           int32

-  ``'i64``           int64

+  ``'i64``           int64
+  ``'u``             uint

+  ``'u8``            uint8

+  ``'u16``           uint16

+  ``'u32``           uint32

+  ``'u64``           uint64

   ``'f32``           float32

   ``'f64``           float64

 =================    =========================

@@ -3114,6 +3135,10 @@ arguments. If none of its parameters have the type ``var T``
 or ``ref T`` or ``ptr T`` this means no locations are modified. It is a static

 error to mark a proc/iterator to have no side effect if the compiler cannot

 verify this.

+
+As a special semantic rule, the built-in ``echo`` pretends to be free of 
+side effects, so that it can be used for debugging routines marked as
+``noSideEffect``.
 

 **Future directions**: ``func`` may become a keyword and syntactic sugar for a

 proc with no side effects:

diff --git a/lib/system.nim b/lib/system.nim
index 8f5b5da5e..e90ca56e1 100755
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -1662,6 +1662,10 @@ proc echo*[Ty](x: openarray[Ty]) {.magic: "Echo", noSideEffect.}
   ## available for the ECMAScript target too.
   ## Unlike other IO operations this is guaranteed to be thread-safe as
   ## ``echo`` is very often used for debugging convenience.
+  ##
+  ## As a special semantic rule, ``echo`` pretends to be free of
+  ## side effects, so that it can be used for debugging routines marked as
+  ## ``noSideEffect``.
 
 template newException*(exceptn: typeDesc, message: string): expr = 
   ## creates an exception object of type ``exceptn`` and sets its ``msg`` field
diff --git a/todo.txt b/todo.txt
index d20174ac2..f9ed570c7 100755
--- a/todo.txt
+++ b/todo.txt
@@ -1,6 +1,8 @@
 version 0.9.0
 =============
 
+- finish support for unsigned ints
+
 Debug GC session:
 - test sequence of closures; especially that the GC does not leak for those!
 
@@ -23,7 +25,6 @@ New pragmas:
   - implement "closure tuple consists of a single 'ref'" optimization
 
 - document 'do' notation
-- finish support for unsigned ints
 - rethink the syntax: distinction between expr and stmt is unfortunate; 
   indentation handling is quite complex too; problem with exception handling
   is that often the scope of ``try`` is wrong and apart from that ``try`` is
diff --git a/web/news.txt b/web/news.txt
index 8a53b6853..aa255a0b1 100755
--- a/web/news.txt
+++ b/web/news.txt
@@ -119,6 +119,7 @@ Language Additions
   allowing for *sigil-like* operators.
 - Stand-alone ``finally`` and ``except`` blocks are now supported.
 - Macros and templates can now be invoked as pragmas.
+- The apostrophe in type suffixes for numerical literal is now optional.
 
 
 2012-02-09 Version 0.8.14 released