Overview

Introduction

miparser is the grammar for SimpleParse the python module to parse the Mental Ray .mi file. It is based of the Yacc scene description from Mental Ray 3.6.1 so it would support the version and compatible with older version mi description as well.

There is already a python lex/yacc(ply) solution for mi parsing which you can find at Google Code: http://code.google.com/p/miparser/

Prerequisit

SimpleParse v2.1.0 which you can get from here: http://simpleparse.sourceforge.net/

Installation

Put the miparser/miparser in your path.

Usage

  1. miparser/miparser.py

    This is the grammar file converted from the mi scene desctiption which I make a copy from the Mental Ray manual:

    example/mi_scene_fil_grammar.3.6.1.y
    

    The __main__ section of the miparser.py demonstrate how it can be used to generate a parsing result tree dictionary for a giving mi file.

  2. miparser/dispatchprocessor.py

    This is a modified version of the original dispatchprocessor.py in the SimpleParse package. The difference is only one line which will prevent the parsing process from throwing exception when a production-handling method is not found. Using the original dispatchprocessor.py, you need to write every production-handling methods. Unless you want to write a mi syntax compatible renderer, you would not usually write out all the production-handling methods.

  3. examples/miprocessor.py is a demo on how to convert the result trees of mi instances into python dict, only the instance flags is converted.