Flex analyses the way
Flex analyses the way
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? ? ? ? ?
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
You are kidding me! Are you being sarcastic or what? That makes absoultely no sense whatsoever!jack wrote: you can't understand me?sorry...
thanks.
Re:Flex analyses the way
--> 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.But it need and recognise next Token either,why recognise 'The Next Token' of the yytext among Flex? ? ? ? ?--> This's nothingdear all,could you tell me... thanks!!!--> Completion of the last sentence. Probably mixed up the thanks!!! which should've been at the end of the text.All there is--> 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)'Look Ahead ' this concept in morphological analysis and syntactic analysis.
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 )--> 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.Whether 'Look Ahead' in morphological analysis just needs 'Look Ahead' in order to match the longest Pattern ,
Anyway, that's just my two cents.
Edit: Keeps on placing quotes at the beginning
-Kon-Tiki-
Re:Flex analyses the way
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
btw. co-ns-ti-pa-ti-on Ya gotta loveit
Re:Flex analyses the way
Sorry,I haven't that mean.smartguy240 wrote:You are kidding me! Are you being sarcastic or what? That makes absoultely no sense whatsoever!jack wrote: you can't understand me?sorry...
thanks.
Please don't think like that !
Re:Flex analyses the way
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?
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
Is this an agi related question? Because you're on the wrong board for that.
Re:Flex analyses the way
Sounds like an OS question for a Dos-like OS.
There is a board for that here too, but this isn't it.
There is a board for that here too, but this isn't it.
Re:Flex analyses the way
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
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
Thanks!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
In Flex, yytext appear with point and array, what is the feature of the two mode? Advantage and disadvantage?
Re:Flex analyses the way
From the flex manual.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
- Nick
Re:Flex analyses the way
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
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