X-Git-Url: http://nitlanguage.org?ds=sidebyside diff --git a/src/parser/xss/lexer.xss b/src/parser/xss/lexer.xss index 843a52b..fccb57c 100644 --- a/src/parser/xss/lexer.xss +++ b/src/parser/xss/lexer.xss @@ -22,10 +22,10 @@ $ template make_lexer() # It is better user with the Parser class Lexer # Last peeked token - attr _token: Token + attr _token: nullable Token # Lexer current state - attr _state: Int + attr _state: Int = 0 # Name of the stream (as given to tokens) readable attr _filename: String @@ -34,25 +34,25 @@ class Lexer attr _stream: IStream # Pushback buffer to store unread character - attr _stream_buf: String + attr _stream_buf: Buffer # Number of character stored in the pushback buffer attr _stream_pos: Int # Current line number in the input stream - attr _line: Int + attr _line: Int = 0 # Current column in the input stream - attr _pos: Int + attr _pos: Int = 0 # Was the last character a cariage-return? - attr _cr: Bool + attr _cr: Bool = false # If the end of stream? - attr _eof: Bool + attr _eof: Bool = false # Current working text read from the input stream - attr _text: String + attr _text: Buffer $ foreach {lexer_data/state} # Constante state values @@ -63,10 +63,10 @@ $ end foreach init(stream: IStream, fname: String) do _filename = fname - _text = new String + _text = new Buffer _stream = stream _stream_pos = -1 - _stream_buf = new String + _stream_buf = new Buffer build_goto_table build_accept_table end @@ -77,7 +77,7 @@ $ end foreach while _token == null do _token = get_token end - return _token + return _token.as(not null) end # Give and consume the next token @@ -88,11 +88,11 @@ $ end foreach result = get_token end _token = null - return result + return result.as(not null) end # Get a token, or null if it is discarded - private meth get_token: Token + private meth get_token: nullable Token do var dfa_state = 0 @@ -178,10 +178,10 @@ $ foreach {//token} $ if {not(@text)} $ if {@parser_index} var token_text = _text.substring(0, accept_length) - var token = new @ename(token_text, _filename, start_line + 1, start_pos + 1) + var token = new @ename.init_tk(token_text, _filename, start_line + 1, start_pos + 1) $ end $ else - var token = new @ename(_filename, start_line + 1, start_pos + 1) + var token = new @ename.init_tk(_filename, start_line + 1, start_pos + 1) $ end push_back(accept_length) _pos = accept_pos