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

SCM Repository

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

View of /branches/charisee_dev/doc/report/grammar-defs.tex

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3269 - (download) (as text) (annotate)
Fri Oct 9 00:54:03 2015 UTC (3 years, 9 months ago) by cchiw
File size: 6613 byte(s)
dev branch
%!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{StrandDecl}}
    \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{\StrandDeclRULES}{
  \begin{Rules}{StrandDecl}
    \RHS{\kw{strand} \term{Id} \kw{(} \nt{Params} \kw{)} \kw{\{} \LISTGRP{\nt{StrandStateDecl}} \LISTONEGRP{\nt{StrandMethod}} \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{\StrandStateDeclRULES}{
  \begin{Rules}{StrandStateDecl}
    \RHS{\OPT{\kw{output}} \nt{VarDecl}}
  \end{Rules}}
\newcommand{\StrandMethodRULES}{
  \begin{Rules}{StrandMethod}
    \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{\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}}
    \RHS{\nt{ValueType} \LISTGRP{\kw{\{} \term{Int} \kw{\}}}}
  \end{Rules}}
\newcommand{\ValueTypeRULES}{
  \begin{Rules}{ValueType}
    \RHS{\kw{tensor} \nt{Dimensions}}
    \RHS{\kw{real}}
    \RHS{\kw{vec2}}
    \RHS{\kw{vec3}}
    \RHS{\kw{vec4}}
    \RHS{\kw{bool}}
    \RHS{\kw{int}}
    \RHS{\kw{string}}
  \end{Rules}}
\newcommand{\DimensionsRULES}{
  \begin{Rules}{Dimensions}
    \RHS{\kw{[} \OPTGRP{\term{Int} \LISTGRP{\kw{,} \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{PowerExpr} \LISTGRP{\nt{MulOp} \nt{PowerExpr}}}
  \end{Rules}}
\newcommand{\PowerExprRULES}{
  \begin{Rules}{PowerExpr}
    \RHS{\nt{ProbeExpr} \LISTGRP{\kw{\^} \nt{ProbeExpr}}}
  \end{Rules}}
\newcommand{\ProbeExprRULES}{
  \begin{Rules}{ProbeExpr}
    \RHS{\nt{PrefixExpr} \OPTGRP{\kw{@} \nt{AtomExpr}}}
  \end{Rules}}
\newcommand{\PrefixExprRULES}{
  \begin{Rules}{PrefixExpr}
    \RHS{\nt{SuffixExpr}}
    \RHS{\kw{-} \nt{PrefixExpr}}
    \RHS{\kw{!} \nt{PrefixExpr}}
    \RHS{\kw{D} \nt{PrefixExpr}}
  \end{Rules}}
\newcommand{\SuffixExprRULES}{
  \begin{Rules}{SuffixExpr}
    \RHS{\nt{DerivExpr} \LIST{\nt{Suffix}}}
  \end{Rules}}
\newcommand{\SuffixRULES}{
  \begin{Rules}{Suffix}
    \RHS{\kw{(} \nt{Arguments} \kw{)}}
    \RHS{\kw{[} \nt{Index} \LISTGRP{\kw{,} \nt{Index}} \kw{]}}
    \RHS{\kw{\{} Expr \kw{\}}}
  \end{Rules}}
\newcommand{\IndexRULES}{
  \begin{Rules}{Index}
    \RHS{\kw{:}}
    \RHS{\nt{Expr}}
  \end{Rules}}
\newcommand{\DerivExprRULES}{
  \begin{Rules}{DerivExpr}
    \RHS{\nt{AtomExpr}}
    \RHS{\nt{$\mathbf{\nabla}$} \nt{AtomExpr}}
    \RHS{\nt{$\mathbf{\nabla\otimes}$} \nt{DerivExpr}}
    \RHS{\nt{$\mathbf{\nabla\times}$} \nt{DerivExpr}}
    \RHS{\nt{$\mathbf{\nabla\bullet}$} \nt{DerivExpr}}
  \end{Rules}}
\newcommand{\AtomExprRULES}{
  \begin{Rules}{AtomExpr}
    \RHS{\term{Id}}
    \RHS{\kw{identity} \kw{[} \term{Int} \kw{]}}
    \RHS{\kw{zeros} \nt{Dimensions}}
    \RHS{\kw{real} \kw{(} \nt{Expr} \kw{)}}
    \RHS{\kw{(} \nt{Expr} \LISTGRP{\kw{,} \nt{Expr}} \kw{)}}
    \RHS{\kw{\{} \nt{Expr} \LISTGRP{\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} \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{$\mathbf{\circledast}$}
    \RHS{$\mathbf{\otimes}$}
    \RHS{$\mathbf{\bullet}$}
  \end{Rules}}

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