Règles de grammaires de ctigre (1)

programme ::=  expression 

expression  ::= 
       primary-expression
     | construction-expression
     | nary-expression
     | sequencing-expression

primary-expression  ::=  
       ident
    |  constant
    |  ( expression )
    |  begin expression end

construction-expression  ::= 
    |  type-id [ expression ] of expression
    |  type-id { label = expression {; label = expression } }

nary-expression  ::=  
        ident ( expression {, expression } )
     |  - expression  |  expression bin-op expression
     |  l-value       |  l-value := expression

sequencing-expression  ::=  
        expression ; expression
     |  if expression then expression [  else expression ]
     |  while expression do expression done
     |  for ident = expression (  to |  downto ) expression do expression done
     |  type  type-binding  { and type-binding }  in expression
     |  let  let-binding  { and let-binding }  in expression

l-value ::= ident  |  l-value.label  |  l-value [ expression ]

type-binding  ::=  id = type-expression

type-expression   ::=  
        type-id
  |  { ty-fields }
  |  array of type-id

let-binding ::=
        ident [: type-id ] := expression 
     |  ident ( ty-fields ) [: type-id ] = expression 

ty-fields  ::=  [  ident : type-id  {, ident : type-id } ]
    
bin-op  ::=  + | -  | * | /  | = | <> | < | <= | > | >= 

constant ::= integer-literal | string-literal | nil

type-id  ::=  ident

label  ::=  ident