Class: Bijou::Parse::TextLexer
Instance Attribute Summary collapse
-
#tokenize_arguments ⇒ Object
Returns the value of attribute tokenize_arguments.
Attributes inherited from Lexer
Instance Method Summary collapse
-
#initialize(input) ⇒ TextLexer
constructor
A new instance of TextLexer.
- #next_token ⇒ Object
Methods inherited from Lexer
#column, #diagnostic, #error, #errors, #getc, #is_token_buffered, #line, #peek_token, #pop, #pop_token, #prev_token, #push_token, #set_string_token, #shift_token, #text, #token, #ungetc, #warning, #warnings
Constructor Details
#initialize(input) ⇒ TextLexer
Returns a new instance of TextLexer.
280 281 282 283 |
# File 'lib/bijou/lexer.rb', line 280 def initialize(input) super @tokenize_arguments = false end |
Instance Attribute Details
#tokenize_arguments ⇒ Object
Returns the value of attribute tokenize_arguments.
278 279 280 |
# File 'lib/bijou/lexer.rb', line 278 def tokenize_arguments @tokenize_arguments end |
Instance Method Details
#next_token ⇒ Object
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
# File 'lib/bijou/lexer.rb', line 285 def next_token() if is_token_buffered return shift_token end while ch0 = getc ch = ch0.chr if ch == '"' if @tokenize_arguments return set_string_token('"', true) end elsif ch == "'" if @tokenize_arguments return set_string_token("'", false) end elsif ch == '=' if @tokenize_arguments ch1 = getc if !ch1 # End of stream. return push_token(Token::Char, ch) elsif ch1.chr == '>' return push_token(Token::Operator, "=>") end end elsif ch == '<' ch1 = getc if !ch1 # End of stream. return push_token(Token::Char, ch) elsif ch1.chr == '%' ch2 = getc if ch2.chr == '=' return push_token(Token::TagOpen, "<%=") elsif ch2.chr == '!' return push_token(Token::TagOpen, "<%!") end ungetc(ch2) return push_token(Token::TagOpen, "<%") elsif ch1.chr == '&' return push_token(Token::TagOpen, "<&") elsif ch1.chr == '/' ch2 = getc if ch2.chr == '%' return push_token(Token::TagOpen, "</%") end ungetc(ch2) end ungetc(ch1) end return push_token(Token::Char, ch) end nil end |