Re: BNF form for MMA?

*To*: mathgroup at yoda.physics.unc.edu*Subject*: Re: BNF form for MMA?*From*: Roberto Sierra <73557.2101 at compuserve.com>*Date*: 24 Jun 93 03:30:56 EDT

Regarding David Harrison's message: > I am seeking a Backus-Naur Form or similar formal specification > of Mathematica. Any help would be appreciated. > In case you are interested, the reason for this is that we are > requiring our undergraduates to do a fair amount of programming > in MMA. I know of a "cheater meter" program that identifies > programs that appear to have been copied from each other; it > knows BNF plus some specific languages, and I would like to use > the tool. Not that I expect any of *my* students to register > on the cheater meter scale, or course, but ... Offhand, I don't know of the existence of a publicly available BNF grammar for MMA, though I do remember that a few months ago there was a similar request from Nick Flann at Utah State University (his message is attached). I might be able to suggest a way to simplify the problem, if you're able to 'whack' your students MMA submissions around a bit within MMA itself. The grammar for MMA probably deals mostly with the precedence of the various prefix/infix/postfix operators, when newlines are considered significant, and so on. You might be able to simplify your parsing requirements significantly by exporting your expressions using FullForm, InputForm, CForm, etc., and then writing a much smaller BNF grammar to deal with these simpler formats. For example, by exporting to FullForm, then you don't have to worry about operators at all, since they will look like explicit functions, and all you're left with are elemental constants, identifiers and function calls. Alternatively, by using CForm, you might be able to whack out a suitable subset of the C grammar to accomplish your task. Hope this helps. \\|// - - o o J roberto sierra O tempered microdesigns \_/ 73557.2101 at compuserve.com Attached: Earlier message concerning MMA grammars. ============================================================================= Sender: mathgroup-adm at yoda.physics.unc.edu Received: from yoda.physics.unc.edu by iha.compuserve.com (5.65/5.930129sam) id AA09983; Sun, 2 May 93 04:37:33 -0400 Received: by yoda.physics.unc.edu (4.1/TAS/11-16-88) id AA15726; Sun, 2 May 93 00:52:47 EDT Received: by yoda.physics.unc.edu (4.1/TAS/11-16-88) id AA15722; Sun, 2 May 93 00:52:46 EDT Message-Id: <9305020452.AA15722 at yoda.physics.unc.edu> To: mathgroup at yoda.physics.unc.edu Subject: Compiler/Grammar/Parser in Mathematica? Date: Thu, 29 Apr 93 09:55:06 -0600 From: flann at nick.cs.usu.edu We are investigating the possibility of writing a partial compiler for mathematica, and had the following questions: 1) What work has been done in this area already? (I could find no references?) 2) Is there a published grammar for mathematica programs anywhere? 3) Are there any existing packages that implement parsers in Mathematica? Thanks! Nick Flann, Assistant Professor, Department of Computer Science, Utah State University, Logan, UT 84322-4205. flann at nick.cs.usu.edu