Page 1 of 2
Flex analyses the way
Posted: Sun Jan 12, 2003 7:19 pm
by jack
dear all,could you tell me...
thanks!!!
All there is 'Look Ahead ' this concept in morphological analysis and syntactic analysis. Whether 'Look Ahead' in morphological analysis just needs 'Look Ahead' in order to match the longest Pattern , But it need and recognise next Token either,why recognise 'The Next Token' of the yytext among Flex? ? ? ? ?
Re:Flex analyses the way
Posted: Sun Jan 12, 2003 8:01 pm
by smartguy240
say what now? can you repeat that in english?
Re:Flex analyses the way
Posted: Sun Jan 12, 2003 9:23 pm
by jack
you can't understand me?sorry...
thanks.
Re:Flex analyses the way
Posted: Mon Jan 13, 2003 5:44 am
by smartguy240
jack wrote:
you can't understand me?sorry...
thanks.
You are kidding me! Are you being sarcastic or what? That makes absoultely no sense whatsoever!
Re:Flex analyses the way
Posted: Mon Jan 13, 2003 5:49 am
by mr-t
Damn straight
Re:Flex analyses the way
Posted: Mon Jan 13, 2003 11:00 am
by Kon-Tiki
dear all,could you tell me...
thanks!!!
--> This's nothing
All there is
--> Completion of the last sentence. Probably mixed up the
thanks!!! which should've been at the end of the text.
'Look Ahead ' this concept in morphological analysis and syntactic analysis.
--> Morphological analysis is a linguistic concept. It analyses a sentence/word and checks its morphemes (the smallest part with a meaning in a word (if I'm correct)
E.g.: /Con/ /Sti/ /Pa/ /tion/. I'm not very good at morphological analysis, so that's probably a crappy, buggy example.
--> Syntactic analysis is the analysis of the sentence (There's not for nothing 'syntax' in the name
)
Whether 'Look Ahead' in morphological analysis just needs 'Look Ahead' in order to match the longest Pattern ,
--> I think this's about a morphological analysis of the token 'Look Ahead'. He's analysing those two words and basically says that 'Look Ahead' is the longest pattern available in morphological analysis. I could be wrong again though.
But it need and recognise next Token either,why recognise 'The Next Token' of the yytext among Flex? ? ? ? ?
--> Basically, this means that the thing that comes after 'Look Ahead' needs to be recognized as well. Then he asks something I don't understand. Don't know what that yytext nor the Flex-thing is.
Anyway, that's just my two cents.
Edit: Keeps on placing quotes at the beginning
-Kon-Tiki-
Re:Flex analyses the way
Posted: Mon Jan 13, 2003 2:03 pm
by rwfromxenon
I think this guy is using some kind of English translator. His speech is everywhere.
btw. co-ns-ti-pa-ti-on Ya gotta loveit
Re:Flex analyses the way
Posted: Mon Jan 13, 2003 7:31 pm
by jack
smartguy240 wrote:
jack wrote:
you can't understand me?sorry...
thanks.
You are kidding me! Are you being sarcastic or what? That makes absoultely no sense whatsoever!
Sorry,I haven't that mean.
Please don't think like that !
Re:Flex analyses the way
Posted: Tue Jan 14, 2003 2:15 am
by jack
Thanks a lot! Please give me a forgiveness for my bad english
There is the concept named Look Ahead both parser and Lexer. In order to match the longest Token in all pattern
matching rules in lexer,lexer need looking ahead,but not need get the next Token! why do we get the next Token in yytext in flex?
Re:Flex analyses the way
Posted: Tue Jan 14, 2003 8:18 pm
by SGreenslade
Is this an agi related question? Because you're on the wrong board for that.
Re:Flex analyses the way
Posted: Wed Jan 15, 2003 12:09 pm
by rwfromxenon
Sounds like an OS question for a Dos-like OS.
There is a board for that here too, but this isn't it.
Re:Flex analyses the way
Posted: Wed Jan 15, 2003 6:20 pm
by sonneveld
LEX (or FLEX, which is the version he's using) is a "lexical analyser" (I think this is what he means by morphological) which breaks up strings of text into tokens. so something like
if (blah == 10)
would equal
IF OPENBRACKET SYMBOL EQUALS CONSTANT CLOSEBRACKET
it's very useful for when you're writing a parser or compiler because it's easier to handle tokens than groups of strings. Each token is usually identified by a regular expression.
that's just one stage of it though. You usually need to take these tokens and organise them into some sort of tree structure so you can easily traverse it.
The syntactic analysis is for that. Usually you use a program like YACC or BISON. They look at groups of tokens and try and find patterns. It's these patterns that help it find "if" statements or a complex algorithm.
Syntactic analysis is usually more recursive and requires a stack. This is different from a lexical which uses regular expressions.
lookahead:
generally, we want to find the longest match. so you want to keep on looking ahead until you've exhausted all avenues. also, in fortran (for eg), you can use keywords like "if" as identifiers so you might need to look ahead to see if it's an identifier or a keyword.
similar to yacc. if you have something like
if (blah) {} else {}
once if gets past "if (blah) {}" it will need to continue looking ahead to see if there's an else after it.
basically, if you have two things that need to be matched and they have similar beginnings.. it will need to lookahead to see which one it is. it makes it a problem when you want some bits parsed before the lexer kicks in again.
now, this is from how I understand it. i might be off in some places.
- Nick
Re:Flex analyses the way
Posted: Thu Jan 16, 2003 10:44 pm
by jack
Nick Sonneveld wrote:
LEX (or FLEX, which is the version he's using) is a "lexical analyser" (I think this is what he means by morphological) which breaks up strings of text into tokens. so something like
Thanks!
In Flex, yytext appear with point and array, what is the feature of the two mode? Advantage and disadvantage?
Re:Flex analyses the way
Posted: Fri Jan 17, 2003 1:17 am
by sonneveld
The advantage of using `%pointer' is substantially faster scanning and no buffer overflow when matching very large tokens (unless you run out of dynamic memory). The disadvantage is that you are restricted in how your actions can modify yytext, and calls to the `unput()' function destroys the present contents of yytext, which can be a considerable porting headache when moving between different lex versions.
The advantage of `%array' is that you can then modify yytext to your heart's content, and calls to `unput()' do not destroy yytext
From the flex manual.
- Nick
Re:Flex analyses the way
Posted: Tue Jan 21, 2003 10:48 pm
by jack
thanks a lot!!!!!!!!!!!!!!!!!!!!!!!!!!
Point is the default mode of the yytext in flex !;But we cann't use use %array when generating C++ scanner classes. But why?Please