model: bring back call site doc to highlight as `CallSite::mdoc_or_fallback`
[nit.git] / contrib / nitcc / src / nitcc_lexer0.nit
index 91767bf..f3ff58d 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-# Ad-hoc hand-writen lexer for nitcc
-# This avoid to commit (and relyon ) a generated lexer
-#
+# Ad-hoc hand-written lexer for nitcc
+# This avoid to commit (and rely on) a generated lexer
 module nitcc_lexer0
 
 # Required for the tokens definitions
 import nitcc_parser
 
-# Hand-writen lexer of nitcc
-# Used only for the boostrap of the tool.
+# Hand-written lexer of nitcc.
+# Used only for the bootstrap of the tool.
 class Lexer_nitcc
+       # The text to tokenize
        var text: String
 
-       var iter: Iterator[Char] = "".iterator
+       # The iterator on text
+       private var iter: Iterator[Char] is noinit
+
+       # The current position
        var pos = 0
 
-       var tokens = new Array[NToken]
+       # The tokens currently produced
+       private var tokens = new Array[NToken]
 
+       # Tokenize and returns the tokens
        fun lex: Array[NToken]
        do
-               iter = text.iterator
+               iter = text.chars.iterator
                while iter.is_ok do
                        trim
                        if not iter.is_ok then break
@@ -62,6 +67,8 @@ class Lexer_nitcc
                                tokens.add new Nccur
                        else if c == '|' then
                                tokens.add new Npipe
+                       else if c == ',' then
+                               tokens.add new Ncomma
                        else if c == ':' then
                                tokens.add new Ncolo
                        else if c == ';' then
@@ -86,15 +93,15 @@ class Lexer_nitcc
                return tokens
        end
 
-       fun error(c: Char)
+       private fun error(c: Char)
        do
                print "pos {pos}: Lexer error on '{c}'."
                abort
        end
 
-       fun str
+       private fun str
        do
-               var b = new Buffer
+               var b = new FlatBuffer
                b.add('\'')
                while iter.is_ok do
                        var c = iter.item
@@ -119,9 +126,9 @@ class Lexer_nitcc
                abort
        end
 
-       fun id(c: Char)
+       private fun id(c: Char)
        do
-               var b = new Buffer
+               var b = new FlatBuffer
                b.add c
                while iter.is_ok do
                        c = iter.item
@@ -136,9 +143,9 @@ class Lexer_nitcc
                tokens.add token
        end
 
-       fun kw(c: Char)
+       private fun kw(c: Char)
        do
-               var b = new Buffer
+               var b = new FlatBuffer
                b.add c
                while iter.is_ok do
                        c = iter.item
@@ -153,7 +160,7 @@ class Lexer_nitcc
                tokens.add token
        end
 
-       fun trim
+       private fun trim
        do
                while iter.is_ok and iter.item <= ' ' do
                        iter.next