Table of Contents

HipHop Formal Syntax

Formal syntax

<Expression>  ... | <HHExprStatement>

<HHExprStatement>  hiphop <HHStatement>

<HHStatement>  <HHPragma>
  | <HHModule>
  | <HHInterface>
  | <HHSeq>
  | <HHLet>
  | <HHSignal>
  | <HHHalt>
  | <HHFork>
  | <HHEmit>
  | <HHSustain>
  | <HHAbort>
  | <HHWeakabort>
  | <HHSuspend>
  | <HHLoop>
  | <HHAsync>
  | <HHRun>
  | <HHEvery>
  | <HHDo>
  | <HHIf>
  | <HHTrap>
  | <HHBreak>
  | <HHYield>
  | <HHAwait>
  | <HHDollarExpression>
  | <HHExpression> ; 

<HHPragma>  pragma { <Statement> }

<HHBlock>  {}
  | { <HHStatement> }
  | { <HHStatement> ... <HHStatement> }

<HHModule>  module <HHMachineModule>

<HHMachineModule>  [ <Identifier> ] [implements <MirrorIntfList>] ( <FormalVarList> ) { <FormalSignalList> <HHStatement>+ }

<HHInterface>  interface [ <Identifier> ] [extends <IntfList>] { <FormalSignalList> }

<MirrorIntfList>  [mirror] <Intf>, ... [mirror] <Intf>

<IntfList>  <Intf>, ... <Intf>

<Intf>  <HHDollarIdent>

<FormalVarList>  | <FormalVar>, ... <FormalVar>

<FormalVar>  <Identifier> | <Identifier> = <Expression>

<FormalSignalList>  | <GlobalSignal>, ... <GlobalSignal>

<GlobalSignal>  <Direction> <Signal>, ... <Signal>
  | <Direction> "..." <Identifier>, ..., <Identifier> <SignalAttr>
  | <Direction> "..." <HHDollarExpression> <SignalAttr>

<Direction>  | in | out | inout

<Signal>  <Identifier> <SignaAttr>

<SignalAttr> ->
  | <Combine>
  | = <HHExpression> <Combine>
  | = <HHExpression> <Combine> transient
  | = <HHExpression> transient
  
<Combine>  | combine <Expression>

<HHAwait>  await <HHDelay>

<HHExpression>  <Expression>
  | <Identifier>.now
  | <Identifier>.pre
  | <Identifier>.nowval
  | <Identifier>.preval
  | <Identifier>.signame
  | this[<Expression>].now
  | this[<Identifier>].pre
  | this[<Identifier>].nowval
  | this[<Identifier>].preval
  | this[<Identifier>].signame

<HHDelay>  ( <HHExpression> )
  | count( <HHExpression>, <HHExpression> )
  | immediate( <HHExpression> )

<HHLet>  let <Declaration> ... <Declaration>

<Declaration>  <Identifier> | <Identifier> = <HHExpression>

<HHSignal>  signal <Signal> | signal [mirror] <Intf>

<HHalt>  halt

<HHSeq>  [ <String> ] <HHBlock>

<HHFork>  fork [ <String> ] <HHBlock> [ par <HHBlock> ... par <HHBlock> ]
  | fork <HHDollarExpression>

<HHSignalName>  <Identifier>
  | <HHDollarExpression>
  
<HHEmit>  emit <HHSignalName>()
  | emit <HHSignalName> ( <HHExpression> )

<HHSustain>  sustain <HHSignalName>()
  | sustain <HHSignalName> ( <HHExpression> )

<HHAbort>  abort <HHDelay> <HHBlock>

<HHWeakabort>  weakabort <HHDelay> <HHBlock>

<HHSuspend>  suspend <HHDelay> <HHBlock>
  | suspend from <HHDelay> to <HHDelay> <HHBlock>
  | suspend from <HHDelay> to <HHDelay> emit <Identifier>() <HHBlock>
  | suspend toggle <HHDelay> <HHBlock>
  | suspend toggle <HHDelay> emit <Identifier>() <HHBlock>

<HHLoop>  loop <HHBlock>

<HHAsync>  async ( [ <HHSignalName> ] ) HHBLock <HHAsyncKill> <HHAsyncSuspend> <HHAsyncResume>

<HHAsyncKill>  | kill <HHBlock>

<HHAsyncSuspend>  | suspend <HHBlock>

<HHAsyncResume>  | resume <HHBlock>

<HHRun>  run <HHRunModule> ( <HHRunExpressions> ) { <HHRunSigs> }
  | run <HHRunModule> ( <HHRunExpressions> ) <HHDollarExpression>

<HHRunModule>  <Ident> | <HHDollarExpression>

<HHRunExpressions>  | | <HHExpression>, ... <HHExpression>

<HHRunSigs>  | <HHRunSig> , ... <HHRunSig>

<HHRunSig>  <Identifier>
  | <Identifier> as <Identifier>
  | *
  | +

<HHEvery>  every <HHDelay> <HHBlock>

<HHDo>  do <HHBlock> every <HHDelay>

<HHIf>  if( <HHExpression> ) <HHStatement>
  | if( <HHExpression> ) <HHStatement> else <HHStatement>

<HHTrap>  <HHLabel> : <HHStatement>

<HHbreak>  break <HHLabel>

<HHYield>  yield

<HHDollarExpression>  ${ <Expression> }

<HHDollarIdent>  <HHDollarExpression> | <Identifier>