Re: [Flex-help] I really thank you for your advice. Arthur Schwarz.
flex is a tool for generating scanners
Brought to you by:
wlestes
From: Arthur S. <asc...@at...> - 2015-07-07 15:17:28
|
I mean that for input streams "abcdefg", I want both pattern /abcd/ and /bcd/ be active. I know that lex/flex generates a token for input streams. I want multiple tokens be generated simultaneously(concurrently) for input streams. 1: Token return is a developer concern. That is, flex allows recognition of a lexeme, the developer provides a return value which is the representative token. 2: Once /abcd/ is recognized then your choices are: a. return two tokens via something like token[0] = value0; token[1] = value1; return token; b. backup 3 characters to reread "bcd" and then return token = "abcd" The caller must now call the lexer to get a token For "bcd". 3: The notion of 'active' does not apply. The lexer works by Reading an input stream until a pattern is matched, then entering the user code for handling the pattern. The user code decides on what to do with the pattern once seen. At the point that a pattern is being processed, we can say that the pattern in 'active', however this is not a common way of addressing that the pattern has been accepted. 4: Someone else remarked that once /abcd/ has been accepted, then by default the substring "bcd" is known. As seen in 2 a) and 2 b) the user code capitalizes on this knowledge by generating the appropriate action, in 2 a) two tokens are return, in 2 b) one token is returned for "abcd" and after a call by the parser, another token is returned for "bcd" 5: Since "bcd" is a substring of "abcd" there is no real need for there to be two patterns, /abcd/ and /bcd/. The issue of simultaneity is mystifying. If there is a single caller (the parser), then that caller usually expects a single response, the return value(s). Concurrency doesn't arise. If there are multiple tasks and the lexer supports their activation depending on whether it sees "abcd" or "bcd" and the desire is to activate two tasks (one for "abcd" and one for "bcd" then the user code does this by using whatever primitives are available. But there is no way in C++ to get true simultaneity. The actions are serial, and even in a multitasking environment, the actions are serial with pseudo-parallelism accomplished 'concurrently'. If this is not the answer that suits your problem, please explain your problem. art |