로딩중...
검색중...
일치하는것 없음
by::tokenDispatcher 클래스 참조

Token queue management for parser 더 자세히 ...

#include <tokenDispatcher.hpp>

Public 멤버 함수

void add (nint newToken)
 
void addFront (nint newToken)
 
nbool pop (nint &output)
 Removes a token from the front of the queue.
 
ncnt len () const
 
void rel ()
 

상세한 설명

Token queue management for parser

Manages a queue of tokens for lookahead and token reordering during parsing. Provides FIFO token dispatch with front insertion capability.

must return token in your rule after using dispatcher

if you don't return a token in flex file, dispatcher won't work. it's by implementation of flex. for example,

PS.getDispatcher().add('+');
// you didn't return here because you want to feed '+' back.
// however, by implementation of flex, there is no chance
// to trigger tokenDispatcher.
}
PS.getDispatcher().add('+');
return STRVAL; // you returns some token. now next token will be '+'.
}
Definition tnarr.hpp:9

only takes token, not character

you may confuse that this class is just like unput(), but it's totally different. unput() affects stream itself. however, tokenDispatchers skips lexer and returns determined token forcely, not a single character. for example,

auto& disp = PS.getDispatcher();
disp.add('n');
disp.add('a');
disp.add('m');
disp.add('e');

you may think that above codes exactly same to ‘unput('e’); unput('m'); ....‘. but that's not true. if you use unput(), lexer will judge the token as STRVAL which contains string value, "name". however, above codes, returns 'n’ token individually to parser which makes it fail to continue.

멤버 함수 문서화

◆ pop()

nbool by::tokenDispatcher::pop ( nint & output)

Removes a token from the front of the queue.

매개변수
outputReference to store the popped token ID.
반환값
true if a token was successfully popped, false if the queue was empty.

이 클래스에 대한 문서화 페이지는 다음의 파일로부터 생성되었습니다.:
to Top