Next  |  Prev  |  Top  |  JOS Index  |  JOS Pubs  |  JOS Home  |  Search

Syntax diagrams

A formal description of the language acceptable to MATLAB, as well as a flow chart of the MATLAB program, is provided by the syntax diagrams or syntax graphs of Wirth [6]. There are eleven non-terminal symbols in the language:

   line, statement, clause, expression, term,
   factor, number, integer, name, command, text .
The diagrams define each of the non-terminal symbols using the others and the terminal symbols:
   letter -- A through Z,
   digit  -- 0 through 9,
   char   -- ( ) ; : + - * / \ = . , < >
   quote  -- '

line

       |-----> statement >----|
       |                      |
       |-----> clause >-------|
       |                      |
-------|-----> expr >---------|------>
     | |                      | |
     | |-----> command >------| |
     | |                      | |
     | |-> > >-> expr >-> < >-| |
     | |                      | |
     | |----------------------| |
     |                          |
     |        |-< ; <-|         |
     |--------|       |---------|
              |-< , <-|

statement

     |-> name >--------------------------------|
     |          |                              |
     |          |         |--> : >---|         |
     |          |         |          |         |
     |          |-> ( >---|-> expr >-|---> ) >-|
     |                  |              |       |
-----|                  |-----< , <----|       |--> = >--> expr >--->
     |                                         |
     |       |--< , <---|                      |
     |       |          |                      |
     |-> < >---> name >---> > >----------------|

clause

     |---> FOR   >---> name >---> = >---> expr >--------------|
     |                                                        |
     | |-> WHILE >-|                                          |
     |-|           |-> expr >----------------------           |
     | |-> IF    >-|          |   |   |   |   |   |           |
-----|                        <   <=  =   <>  >=  >           |---->
     |                        |   |   |   |   |   |           |
     |                        ----------------------> expr >--|
     |                                                        |
     |---> ELSE  >--------------------------------------------|
     |                                                        |
     |---> END   >--------------------------------------------|

expr

       |-> + >-|
       |       |
-------|-------|-------> term >---------->
       |       |    |             |
       |-> - >-|    |  |-< + <-|  |
                    |  |       |  |
                    |--|-< - <-|--|
                       |       |
                       |-< : <-|

term

---------------------> factor >---------------------->
        |                                   |
        |             |-< * <-|             |
        |  |-------|  |       |  |-------|  |
        |--|       |--|-< / <-|--|       |--|
           |-< . <-|  |       |  |-< . <-|
                      |-< \ <-|

factor

     |----------------> number >---------------|
     |                                         |
     |-> name >--------------------------------|
     |          |                              |
     |          |         |--> : >---|         |
     |          |         |          |         |
     |          |-> ( >---|-> expr >-|---> ) >-|
     |                  |              |       |
     |                  |-----< , <----|       |
     |                                         |
-----|------------> ( >-----> expr >-----> ) >-|-|-------|----->
     |                                         | |       | |
     |                  |--------------|       | |-> ' >-| |
     |                  |              |       |           |
     |------------> < >-|---> expr >---|-> > >-|           |
     |                    |          |         |           |
     |                    |--<   <---|         |           |
     |                    |          |         |           |
     |                    |--< ; <---|         |           |
     |                    |          |         |           |
     |                    |--< , <---|         |           |
     |                                         |           |
     |------------> > >-----> expr >-----> < >-|           |
     |                                         |           |
     |-----> factor >---> ** >---> factor >----|           |
     |                                                     |
     |------------> ' >-----> text >-----> ' >-------------|

number

    |----------|                          |-> + >-|
    |          |                          |       |
-----> int >-----> . >---> int >-----> E >---------> int >---->
             |                   | |      |       |        |
             |                   | |      |-> - >-|        |
             |                   | |                       |
             |---------------------------------------------|

int

------------> digit >----------->
          |           |
          |-----------|

name

                  |--< letter <--|
                  |              |
------> letter >--|--------------|----->
                  |              |
                  |--< digit  <--|

command

                        |--> name >--|
                        |            |
--------> name >--------|------------|---->
                        |            |
                        |--> char >--|
                        |            |
                        |---> ' >----|

text

                |-> letter >--|
                |             |
                |-> digit >---|
----------------|             |-------------->
            |   |-> char >----|   |
            |   |             |   |
            |   |-> ' >-> ' >-|   |
            |                     |
            |---------------------|


Next  |  Prev  |  Top  |  JOS Index  |  JOS Pubs  |  JOS Home  |  Search