简体   繁体   中英

is this grammar context free

is the following grammar context free? My impression was that a grammar was context free when the parser did not need to interpret what was parsed already. With the following grammar, that is not necessary, however, my colleague is sure that it is context sensitive non the less.

The issue is that you cannot determine which alternative of X needs to be matched without knowing if X is inside Y or Z

X: ( "a" | "a" "b" )
Y: X "b" "c"
Z: X "d"

The term "context sensitive" occasionally arises when discussing grammars that work with LL parsers but not with Strong LL (SLL) parsers. In these cases, decisions that require an LL parser may be called "context sensitive" because they require information about the top-down parsing context to make accurate decisions. However, both SLL and LL grammars would be considered context-free grammars.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM