Class: Bijou::Parse::TagLexer
Instance Attribute Summary collapse
-
#tokenize_arguments ⇒ Object
Returns the value of attribute tokenize_arguments.
Attributes inherited from Lexer
Instance Method Summary collapse
-
#initialize(input) ⇒ TagLexer
constructor
A new instance of TagLexer.
- #next_token ⇒ Object
- #parse_string(stringType) ⇒ Object
- #start(tok, type) ⇒ 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) ⇒ TagLexer
Returns a new instance of TagLexer.
353 354 355 356 357 358 |
# File 'lib/bijou/lexer.rb', line 353 def initialize(input) super(input) @startToken = nil @tagType = nil @tokenize_arguments = false end |
Instance Attribute Details
#tokenize_arguments ⇒ Object
Returns the value of attribute tokenize_arguments.
351 352 353 |
# File 'lib/bijou/lexer.rb', line 351 def tokenize_arguments @tokenize_arguments end |
Instance Method Details
#next_token ⇒ Object
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
# File 'lib/bijou/lexer.rb', line 380 def next_token() if is_token_buffered return shift_token end while ch0 = getc ch = ch0.chr #puts "Read: '#{ch}' #{@tagType}" if ch == '"' return set_string_token('"', true) elsif ch == "'" return set_string_token("'", false) elsif ch == '=' if @tokenize_arguments ch1 = getc if ch1.chr == '>' return push_token(Token::Operator, "=>") end end elsif ch == '%' ch1 = getc if ch1.chr == '>' # if @startToken == '<%=' || @startToken == '<%' || # @startToken == '</%' || @startToken == '<%!' return push_token(Token::TagClose, "%>") # else # warning("unexpected '%>' tag close") # end end ungetc(ch1) elsif ch == '&' ch1 = getc if ch1.chr == '>' # if @startToken == '<&' return push_token(Token::TagClose, "&>") # else # warning("unexpected '&>' tag close") # end end ungetc(ch1) elsif ch == '>' if @tagType == TagType::Named || @tagType == TagType::Directive return push_token(Token::TagClose, ">") else # For inline and calls, we ignore this case, because it may # be '=>' '>=', etc., which are valid expressions. # REVIEW: This can cause problems. # BUGBUG: When parsing <%init>, for example, we haven't set the # token type because we don't know it yet. # print("#{@startToken} #{@tagType} ***") end end return push_token(Token::Char, ch) end nil end |
#parse_string(stringType) ⇒ Object
360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
# File 'lib/bijou/lexer.rb', line 360 def parse_string(stringType) @lexer = @stringLexer @lexer.type = stringType while tok = @lexer.next_token # print @lexer.text # print before switching lexers if tok == Token::String # print "<" + @lexer.text + ">---" # print @lexer.text @backend.tagString(@lexer.unquoted_string, @lexer.type) return @lexer.raw_string end end end |
#start(tok, type) ⇒ Object
375 376 377 378 |
# File 'lib/bijou/lexer.rb', line 375 def start(tok, type) @startToken = tok @tagType = type end |