Wolfram Library Archive


All Collections Articles Books Conference Proceedings
Courseware Demos MathSource Technical Notes
Title Downloads

Context-Free Grammars
Author

Charles Wells
Organization: Case Western Reserve University
Department: Department of Mathematics
Old MathSource #

0205-456
Revision date

1996-11-19
Description

The Mathematica notebook, ContextFreeGrammar.nb, contains a command AcceptQ that takes a context-free grammar and a string as arguments and determines whether the string is generated by the grammar. As a side effect, it prints successively a list of strings that derive to the given string in n steps. It stops and accepts when it finds the start symbol in that list. If it comes up with the empty list, it rejects.
Subject

*Applied Mathematics > Computer Science
Keywords

context-free grammars, context free grammars, parser, backward exhaustive search, forward breadth first search, derivation tree, formal languages, rewrite
Downloads Download Wolfram CDF Player

Download
ContextFreeGrammar.nb (9.1 KB) - Mathematica notebook

Files specific to Mathematica 2.2 version:
Download
ContextFreeGrammar.ma (5.7 KB) - Mathematica notebook