9 Jan 1997 21:49:17 -0500

Related articles |
---|

Matlab grammar wanted. jaystar@exo.com (J. E. Valstar) (1997-01-07) |

Re: Matlab grammar wanted. jwe@bevo.che.wisc.edu (1997-01-09) |

From: | jwe@bevo.che.wisc.edu (John W. Eaton) |

Newsgroups: | comp.compilers |

Date: | 9 Jan 1997 21:49:17 -0500 |

Organization: | UW-Madison Department of Chemical Engineering |

References: | 97-01-047 |

Keywords: | parse, comment |

J. E. Valstar <jaystar@exo.com> wrote:

*: Does anyone have, or know of, a Matlab or comparable grammar for a*

*: compiler generator such as PCCTS, yacc, or bison. TIA*

Of the freely available systems for doing matrix math, Octave is

probably the closest to Matlab syntax. The parser is written for

bison, but I think it will also work with byacc. Octave is

distributed under the terms of the GPL and is available from

ftp.che.wisc.edu in the directory /pub/octave.

*: [I wrote one on a consulting job a few years ago. The syntax is*

*: pretty simple so it wasn't very hard. I can't give it away, belongs*

*: to the people who I wrote it for. -John]*

I found that it wasn't so trivial to be compatible with Matlab. For

example, given x = [ 1, 2 ], each of the following produce different

results:

[ x (1) -2 ] == [ x, 1, -2 ] ==> [ 1 2 1 -2 ]

[ x (1) - 2 ] == [ x, (1-2) ] ==> [ 1 2 -1 ]

[ x(1) -2 ] == [ x(1), -2 ] ==> [ 1 -2 ]

[ x(1) - 2 ] == [ (x(1)-2) ] ==> -1

But then again, maybe I still haven't seen the light...

--

Octave: http://www.che.wisc.edu/octave

Me: http://www.che.wisc.edu/~jwe

[I didn't say it was trivial, just not terribly hard. As I recall, we

had some kludges for those situations that returned white space as

tokens and then used rules in the parser to do the right thing. -John]

--

Post a followup to this message

Return to the
comp.compilers page.

Search the
comp.compilers archives again.