CMurphi入门笔记(二)——基本概念

原文地址:http://www.cnblogs.com/Rainday/p/cmurphi_prime_2.html

 

1. BNF 

 本系列使用BNF来说明Murphi的语法:

  • <>  代表非终结点
  • []  代表可选部分
  • {}  代表重复零次或者多次
  • a|b  代表a或者b其一
  • ()  代表组

当这些符号的任何一个在Murphi语言中需要用到的话,将会使用反斜杠(即\)进行转义。

 

2. 词法规则

下边这些是Murphi中的保留字:

    alias           array           assert          begin           
    boolean         by              case            clear
    const           do              else            elsif
    end             endalias        endexists       endfor
    endforall       endfunction     endif           endprocedure
    endrecord       endrule         endruleset      endstartstate
    endswitch       endwhile        enum            error
    exists          false           for             forall
    function        if              in              interleaved
    invariant       of              procedure       process
    program         put             record          return
    rule            ruleset         startstate      switch
    then            to              traceuntil      true
    type            var             while

在说明Murphi语法的时候,保留字是不受BNF的限制的。

有些保留字并没有定义任何事情,这是为以后的扩展预留的。这些保留字有:

    in    interleaved    process    program    traceuntil

大小写敏感:Murphi是大小写敏感的,不过保留字除外。"foo"和"Foo"代表不同的标识符,"Begin"和"BeGiN"代表相同的保留字。

同义词:保留字"end"是所有特定类型的end的同义词,也就是说,"end"可以自由取代"endrule","endfor"等保留字。

标识符:标识符是字母、下划线和以字母开头的数字的任意序列。所有以下划线开头的标识符都是系统保留的。标识符在BNF中以<ID>表示。

字符串:字符串在BNF中以<string>表示,是字符的序列,但不用双引号包住。(这一段不是很理解,原文为:A string, referred to in the BNF as <string> is a sequence of
characters other than double quote (\") enclosed in double quotes

整型常量:整型常量是以10为基的,也就是十进制数字,在BNF中表示为<integer-constant>。

注释:在Murphi中有两种类型的注释:Ada风格的注释,以"--"开始,以换行结束;C风格的注释,以"/*"开始,以"*/"结束,注意这种注释是不能嵌套的。

 

3. 程序结构

 Murphi程序具有如下所示的结构,每个结构的含义已经用注释说明:

<Program> ::= { <decl> }    -- Constant, type, and variable declarations
          { <procdecl> }    -- Procedure and function declarations
          { <rules> }       -- rules, startstates, and invariants

一个Murphi程序决定一个状态图。状态是指对每个全局变量的赋值。图中的起始状态由程序中<rules>部分中的startstates定义,之后的状态由程序中<rules>部分中的rules定义。


Murphi的基本概念就是这些了~

 

传送门:

CMurphi入门笔记(一)——概览

CMurphi入门笔记(二)——基本概念

CMurphi入门笔记(三)——定义

CMurphi入门笔记(四)——表达式

CMurphi入门笔记(五)——语句

CMurphi入门笔记(六)——规则,起始状态和不变式

 

 

 

 

posted @ 2013-07-29 20:02  Raindai  阅读(1431)  评论(0编辑  收藏  举报