context-free-grammar

The recognizing power of “modern” regexes

妖精的绣舞 提交于 2019-11-25 23:36:45
问题 What class of languages do real modern regexes actually recognise? Whenever there is an unbounded length capturing group with a back-reference (e.g. (.*)_\\1 ) a regex is now matching a non-regular language. But this, on its own, isn\'t enough to match something like S ::= \'(\' S \')\' | ε — the context-free language of matching pairs of parens. Recursive regexes (which are new to me, but I am assured exist in Perl and PCRE) appear to recognize at least most CFLs. Has anyone done or read any

Is C++ context-free or context-sensitive?

纵饮孤独 提交于 2019-11-25 20:03:01
I often hear claims that C++ is a context-sensitive language. Take the following example: a b(c); Is this a variable definition or a function declaration? That depends on the meaning of the symbol c . If c is a variable , then a b(c); defines a variable named b of type a . It is directly initialized with c . But if c is a type , then a b(c); declares a function named b that takes a c and returns an a . If you look up the definition of context-free languages, it will basically tell you that all grammar rules must have left-hand sides that consist of exactly one non-terminal symbol. Context