parsing - How to test grammar changes in yacc/lalr(1) for backwards compatibilitiy? -


we have our scripting language in use , improving adding new features etc.

my question is; best way test our grammer backwards compatibility? knows tool makes or way it?

best regards

testing whether 1 grammar accepts same language another, or accepts larger language, difficult if not impossible in theory.

as engineers, asked impossible. relax requirements until kind of useful answer. 1 way relax requirements allow tool "don't know" in cases.

my company builds parsers based on parser generators. deal huge grammars (thousands of rules). 1 of mechanisms have been working on detect if grammar ambiguous. known impossible in theory, doesn't change our interest in getting answer.

we working on tool can answer question in many cases. in effect ask if nonterminal ambiguous; applied root grammar rule directly asks if grammar ambiguous. reason trying on nonterminals many of them produce smaller sublanguages full language, allowing them analyzed. determines doing breadth-first search on expansions of nonterminal using grammar rules expand. 1 of several things occurs during search:

  • the nonterminal shown not-ambiguous
  • it shown ambiguous, implies main grammar rule ambiguous
  • the search runs out of time willing spend on it.

by recording search results, , iterating multiple times (using search technique called "iterative deepening") on grammar rules, can find ambiguities, and/or prove parts of grammar not ambiguous. (having cached fact terminal/nonterminal x or not ambiguous allows checking other nonterminals y transitively use x, search "faster" or "deeper"; old trick of transposition tables in chess programs). answer isn't perfect, when identifies ambiguity there one, , when claims there isn't one, there isn't one. that's big help.

it seems me same type of search should applicable asking if 1 grammar accepts superset of another, under assumption grammars similar (e.g., got 1 modifying other "slightly"). search has check each nonterminal shared languages if nonterminal superset of twin. again, answer not perfect, might go long way in providing faith in compatibility.

the other way know how run large set of comprehensive tests, @ejp has noted.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -