Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /trunk/doc/report/grammar-defs.tex
ViewVC logotype

View of /trunk/doc/report/grammar-defs.tex

Parent Directory Parent Directory | Revision Log Revision Log


Revision 378 - (download) (as text) (annotate)
Tue Oct 5 00:22:49 2010 UTC (8 years, 10 months ago) by jhr
File size: 5595 byte(s)
  Added conditional expression syntax
%!TEX root = report.tex
%
% Macros for the various rules of the Diderot grammar.  We collect the
% grammer into these macros to ensure consistency between the collected
% syntax and the body of the text.
%
\newcommand{\ProgramRULES}{
  \begin{Rules}{Program}
    \RHS{\LISTONE{\nt{Declaration}}}
  \end{Rules}}
\newcommand{\DeclarationRULES}{
  \begin{Rules}{Declaration}
    \RHS{\nt{InputDecl}}
    \RHS{\nt{VarDecl}}
    \RHS{\nt{ActorDecl}}
    \RHS{\nt{CoordinationDecl}}
  \end{Rules}}
\newcommand{\InputDeclRULES}{
  \begin{Rules}{InputDecl}
    \RHS{\kw{input} \nt{Type} \term{Id} \OPTGRP{\kw{=} \nt{Expr}} \kw{;}}
  \end{Rules}}
\newcommand{\ActorDeclRULES}{
  \begin{Rules}{ActorDecl}
    \RHS{\kw{actor} \term{Id} \kw{(} \nt{Params} \kw{)} \kw{\{} \LISTGRP{\nt{ActorStateDecl}} \LISTONEGRP{\nt{ActorMethod}} \kw{\}}}
  \end{Rules}}
\newcommand{\ParamsRULES}{
  \begin{Rules}{Params}
    \RHS{\OPTGRP{\nt{Param} \LISTGRP{\kw{,} \nt{Param}}}}
  \end{Rules}}
\newcommand{\ParamRULES}{
  \begin{Rules}{Param}
    \RHS{\nt{ValueType} \term{Id}}
  \end{Rules}}
\newcommand{\ActorStateDeclRULES}{
  \begin{Rules}{ActorStateDecl}
    \RHS{\OPT{\kw{output}} \nt{VarDecl}}
  \end{Rules}}
\newcommand{\ActorMethodRULES}{
  \begin{Rules}{ActorMethod}
    \RHS{\nt{MethodId} \nt{Block}}
  \end{Rules}}
\newcommand{\MethodIdRULES}{
  \begin{Rules}{MethodId}
    \RHS{\kw{update}}
    \RHS{\kw{stabilize}}
    \RHS{\term{Id}}
  \end{Rules}}
\newcommand{\BlockRULES}{
  \begin{Rules}{Block}
    \RHS{\kw{\{} \LISTGRP{\nt{Stmt}} \kw{\}}}
  \end{Rules}}
\newcommand{\StmtRULES}{
  \begin{Rules}{Stmt}
    \RHS{\nt{Block}}
    \RHS{\nt{VarDecl}}
    \RHS{\kw{stabilize} \kw{;}}
    \RHS{\kw{die} \kw{;}}
    \RHS{\kw{new} \term{Id} \kw{(} \nt{Arguments} \kw{)} \kw{;}}
    \RHS{\term{Id} \kw{=} \nt{Expr} \kw{;}}
    \RHS{\kw{if} \kw{(} \nt{Expr} \kw{)} \nt{Stmt} \kw{else} \nt{Stmt}}
    \RHS{\kw{if} \kw{(} \nt{Expr} \kw{)} \nt{Stmt}}
  \end{Rules}}
\newcommand{\VarDeclRULES}{
  \begin{Rules}{VarDecl}
    \RHS{\nt{Type} \term{Id} \kw{=} \nt{Expr} \kw{;}}
  \end{Rules}}
\newcommand{\TypeRULES}{
  \begin{Rules}{Type}
    \RHS{\nt{ValueType} \LISTGRP{\kw{[} \term{Int} \kw{]}}}
    \RHS{\kw{image} \kw{(} \term{Int} \kw{)} \nt{Dimensions}}
    \RHS{\kw{field} \kw{\#} \term{Int} \kw{(} \term{Int} \kw{)} \nt{Dimensions}}
    \RHS{\kw{kernel} \kw{\#} \term{Int}}
  \end{Rules}}
\newcommand{\ValueTypeRULES}{
  \begin{Rules}{ValueType}
    \RHS{\kw{bool}}
    \RHS{\kw{int}}
    \RHS{\kw{string}}
    \RHS{\kw{real}}
    \RHS{\kw{vec2}}
    \RHS{\kw{vec3}}
    \RHS{\kw{vec4}}
    \RHS{\kw{tensor} \nt{Dimensions}}
  \end{Rules}}
\newcommand{\DimensionsRULES}{
  \begin{Rules}{Dimensions}
    \RHS{\kw{[} \OPTGRP{\nt{\term{Int}} \LISTGRP{\kw{,} \nt{\term{Int}}}} \kw{]}}
  \end{Rules}}
\newcommand{\CoordinationDeclRULES}{
  \begin{Rules}{CoordinationDecl}
    \RHS{\kw{initially} \nt{\GRP{\nt{Array} $\;|\;$ \nt{Collection}}} \kw{;}}
  \end{Rules}}
\newcommand{\ArrayRULES}{
  \begin{Rules}{Array}
    \RHS{\kw{[} \nt{Create} \kw{|} \nt{Iterations} \kw{]}}
  \end{Rules}}
\newcommand{\CollectionRULES}{
  \begin{Rules}{Collection}
    \RHS{\kw{\{} \nt{Create} \kw{|} \nt{Iterations} \kw{]}}
  \end{Rules}}
\newcommand{\CreateRULES}{
  \begin{Rules}{Create}
    \RHS{\term{Id} \kw{(} \nt{Arguments} \kw{)}}
  \end{Rules}}
\newcommand{\IterationsRULES}{
  \begin{Rules}{Iterations}
    \RHS{\nt{Iteration} \LISTONEGRP{\kw{,} \nt{Iteration}}}
  \end{Rules}}
\newcommand{\IterationRULES}{
  \begin{Rules}{Iteration}
    \RHS{\term{Id} \kw{in} \nt{Expr} \kw{..} \nt{Expr}}
  \end{Rules}}
\newcommand{\ExprRULES}{
  \begin{Rules}{Expr}
    \RHS{\nt{TestExpr} \OPTGRP{\kw{if} \nt{Expr} \kw{else} \nt{Expr}}}
  \end{Rules}}
\newcommand{\TestExprRULES}{
  \begin{Rules}{TestExpr}
    \RHS{\nt{AndExpr} \LISTGRP{\kw{||} \nt{AndExpr}}}
  \end{Rules}}
\newcommand{\AndExprRULES}{
  \begin{Rules}{AndExpr}
    \RHS{\nt{CmpExpr} \LISTGRP{\kw{\&\&} \nt{CmpExpr}}}
  \end{Rules}}
\newcommand{\CmpExprRULES}{
  \begin{Rules}{CmpExpr}
    \RHS{\nt{AddExpr} \LISTGRP{\nt{CmpOp} \nt{AddExpr}}}
  \end{Rules}}
\newcommand{\AddExprRULES}{
  \begin{Rules}{AddExpr}
    \RHS{\nt{MulExpr} \LISTGRP{\nt{AddOp} \nt{MulExpr}}}
  \end{Rules}}
\newcommand{\MulExprRULES}{
  \begin{Rules}{MulExpr}
    \RHS{\nt{PrefixExpr} \LISTGRP{\nt{MulOp} \nt{PrefixExpr}}}
  \end{Rules}}
\newcommand{\PrefixExprRULES}{
  \begin{Rules}{PrefixExpr}
    \RHS{\nt{SelExpr}}
    \RHS{\kw{-} \nt{PrefixExpr}}
    \RHS{\kw{!} \nt{PrefixExpr}}
    \RHS{\kw{D} \nt{PrefixExpr}}
  \end{Rules}}
\newcommand{\SelExprRULES}{
  \begin{Rules}{SelExpr}
    \RHS{\nt{AtomExp} \LISTGRP{\kw{@} \nt{AtomExp} $\;|\;$ \kw{[} \nt{Expr} \kw{]}}}
  \end{Rules}}
\newcommand{\AtomExpRULES}{
  \begin{Rules}{AtomExp}
    \RHS{\term{Id} \OPTGRP{\kw{(} \nt{Arguments} \kw{)}}}
    \RHS{\kw{real} \kw{(} \nt{Expr} \kw{)}}
    \RHS{\kw{[} \nt{Expr} \LISTGRP{\kw{,} \nt{Expr}} \kw{]}}
    \RHS{\term{Int}}
    \RHS{\term{Float}}
    \RHS{\term{String}}
    \RHS{\kw{(} \nt{Expr} \LISTGRP{\kw{,} \nt{Expr}} \kw{)}}
    \RHS{\kw{|} \nt{Expr} \kw{|}}
  \end{Rules}}
\newcommand{\ArgumentsRULES}{
  \begin{Rules}{Arguments}
    \RHS{\OPTGRP{\nt{Expr} \LISTGRP{\kw{,} \nt{Expr}}}}
  \end{Rules}}
\newcommand{\CmpOpRULES}{
  \begin{Rules}{CmpOp}
    \RHS{\kw{<}}
    \RHS{\kw{<=}}
    \RHS{\kw{==}}
    \RHS{\kw{!=}}
    \RHS{\kw{>=}}
    \RHS{\kw{>}}
  \end{Rules}}
\newcommand{\AddOpRULES}{
  \begin{Rules}{AddOp}
    \RHS{\kw{+}}
    \RHS{\kw{-}}
  \end{Rules}}
\newcommand{\MulOpRULES}{
  \begin{Rules}{MulOp}
    \RHS{\kw{*}}
    \RHS{\kw{/}}
    \RHS{\kw{(*)}}
  \end{Rules}}

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0