开发者

Bison Flex token for every undefined token read

I am looking for a way to parse just a particular part of a file. For example, lets see:

if {$cpf_step == "pre_restruct"} {
create_power_domain     -name domain_GPU_SW \
            -shutoff_condition "!$mali_pso_condition_pin" \
            -instances "$GPU_SW_instances_list"
} else {
create_power_domain     -name开发者_开发知识库 domain_GPU_SW \
            -shutoff_condition "!$mali_pso_condition_pin" 
}               

I am interested in the create_power_domain commands. I have a rule with the different token used in it. Here are the rule I use [EDIT] of course there are things before and after this extract aswell as other create_power_domain commands that i am interested in parsing[/EDIT]

file :list_of_statement
;

list_of_statement: statement
    | list_of_statement statement
    ;

statement: power_domain
| T_EVERY_OTHER_THING_I_READ
;   

power_domain: K_CREATE_POWERDOMAIN K_NAME K_IDENTIFIER options_list

Now as you can understand, i want to only check that each power domain is corresponding to the syntax and I don't want to care about everything else.

In my flex tokenizer, I tried

.* {return T_EVERY_OTHER_THING_I_READ; } but then i remembered that Lex tries to find the longest matching regular expression which implies that everything will now be a T_EVERY_OTHER_THING_I_READ token and i wont find my K_CREATE_POWERDOMAIN for example.

My question is then how do i ignore everything that is not part of the rule i am interested in ?

if you have further question feel free to ask.

Thank you


Assuming that power_domain is delimited by space, tab or newline, excluding those from T_EVERY_OTHER_THING_I_READ should help, so try something like [^\n\r\t ]* {return T_EVERY_OTHER_THING_I_READ; } (untested)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜