Fantom

 

class

compiler::Parser

sys::Obj
  compiler::CompilerSupport
    compiler::Parser

Parser is responsible for parsing a list of tokens into the abstract syntax tree. At this point the CompilationUnit, Usings, and TypeDefs are already populated by the ScanForUsingAndTypes step.

Slots

OnceSource

static Int Once := 2147483648

ParserFlagsMaskSource

static Int ParserFlagsMask := Readonly

ProtectionMaskSource

static Int ProtectionMask := ...

ReadonlySource

static Int Readonly := 1073741824

errSource

override CompilerErr err(Str msg, Loc? loc := null)

Create, log, and return a CompilerErr.

makeSource

new make(Compiler compiler, CompilationUnit unit, ClosureExpr[] closures)

Construct the parser for the specified compilation unit.

parseSource

Void parse()

Top level parse a compilation unit:

<compilationUnit> :=  [<usings>] <typeDef>*
parsePodDefSource

Void parsePodDef()

Parse pod definition:

<podDef>      :=  <podHeader> "{" <symbolDefs> "}"
<podHeader>   :=  [<doc>] <facets> "pod" <id>
<symbolDefs>  :=  <symbolDef>*
typeDefSource

Void typeDef()

TypeDef:

<typeDef>      :=  <classDef> | <mixinDef> | <enumDef>

<classDef>     :=  <classHeader> <classBody>
<classHeader>  :=  [<doc>] <facets> <typeFlags> "class" [<inheritance>]
<classFlags>   :=  [<protection>] ["abstract"] ["final"]
<classBody>    :=  "{" <slotDefs> "}"

<enumDef>      :=  <enumHeader> <enumBody>
<enumHeader>   :=  [<doc>] <facets> <protection> "enum" [<inheritance>]
<enumBody>     :=  "{" <enumDefs> <slotDefs> "}"

<mixinDef>     :=  <enumHeader> <enumBody>
<mixinHeader>  :=  [<doc>] <facets> <protection> "mixin" [<inheritance>]
<mixinBody>    :=  "{" <slotDefs> "}"

<protection>   :=  "public" | "protected" | "private" | "internal"
<inheritance>  :=  ":" <typeList>