difficulty getting c-style comments in flex/lex -


I want to create a rule in Flex such as using a C-style comment like / * * /

< P> I have the following

  c_comment "/*"[\n.]*"*/"  

but it never matches . Any ideas why? If you need more of your code, please let me know and I will submit the whole thing

My Suggest that you use instead

 % X C_COMMENT "/ *" {BEGIN (C_COMMENT); } & Lt; C_COMMENT & gt; "* /" {BEGIN (initial); } & Lt; C_COMMENT & gt; \ N {} & lt; C_COMMENT & gt; {}  

Note that & lt; Condition & gt; and there should be no white space between the rules

% x C_COMMENT C_COMMENT defines the condition, and the rule / * has been started. Once this is started, it will be returned to * / back to the initial state ( initial / code> predefined), and each other characters use it without any special action When two rules meet, Flex takes someone into the longest match, so the dot rule does not stop matching to * / . The rule is required because C_COMMENT is an unique state in the definition

% x , which means the Lexzer < / P>

This is a rule that applies this answer to all by printing which is / * comments * / .


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -