Abstract Syntax Tree

From Gallium

Jump to: navigation, search

Here is the Camlp4 syntactic and abstract representation of OCaml programs:

Contents

Identifiers

QuotationSignificationAST
<:ident< a . b >>Access in moduleIdAcc of Loc.t and ident and ident
<:ident< a b >>ApplicationIdApp of Loc.t and ident and ident
<:ident< $lid:i$ >>Lowercase identifierIdLid of Loc.t and string
<:ident< $uid:i$ >>Uppercase identifierIdUid of Loc.t and string
<:ident< $anti:s$ >>AntiquotationIdAnt of Loc.t and string

Types

QuotationSignificationAST
<:ctyp< >>Empty typeTyNil of Loc.t
<:ctyp< t as t >>Type aliasingTyAli of Loc.t and ctyp and ctyp
<:ctyp< _ >>WildcardTyAny of Loc.t
<:ctyp< t t >>ApplicationTyApp of Loc.t and ctyp and ctyp
<:ctyp< t -> t >>ArrowTyArr of Loc.t and ctyp and ctyp
<:ctyp< #i >>Class typeTyCls of Loc.t and ident
<:ctyp< ~s >>Label typeTyLab of Loc.t and string and ctyp
<:ctyp< $id:i$ >>Type identifierTyId of Loc.t and ident
<:ctyp< t == t >>Type manifestTyMan of Loc.t and ctyp and ctyp
<:ctyp< type t 'a 'b 'c = t constraint t = t constraint t = t >>Type declarationTyDcl of Loc.t and string and list ctyp and ctyp and list (ctyp * ctyp)
<:ctyp< < (t)? (..)? > >>Object typeTyObj of Loc.t and ctyp and meta_bool
<:ctyp< ?s >>Optional label typeTyOlb of Loc.t and string and ctyp
<:ctyp< ! t . t >>Polymorphic typeTyPol of Loc.t and ctyp and ctyp
<:ctyp< 's >>TyQuo of Loc.t and string
<:ctyp< +'s >>TyQuP of Loc.t and string
<:ctyp< -'s >>TyQuM of Loc.t and string
<:ctyp< `s >>Polymorphic variantTyVrn of Loc.t and string
<:ctyp< { t } >>RecordTyRec of Loc.t and ctyp
<:ctyp< t : t >>Field declarationTyCol of Loc.t and ctyp and ctyp
<:ctyp< t; t >>Semicolon-separated type listTySem of Loc.t and ctyp and ctyp
<:ctyp< t, t >>Comma-separated type listTyCom of Loc.t and ctyp and ctyp
<:ctyp< [ t ] >>Sum typeTySum of Loc.t and ctyp
<:ctyp< t of t >>TyOf of Loc.t and ctyp and ctyp
<:ctyp< t and t >>TyAnd of Loc.t and ctyp and ctyp
<:ctyp< t | t >>"Or" pattern between typesTyOr of Loc.t and ctyp and ctyp
<:ctyp< private t >>Private typeTyPrv of Loc.t and ctyp
<:ctyp< mutable t >>Mutable typeTyMut of Loc.t and ctyp
<:ctyp< ( t ) >>TupleTyTup of Loc.t and ctyp
<:ctyp< t * t >>TySta of Loc.t and ctyp and ctyp
<:ctyp< [ = t ] >>TyVrnEq of Loc.t and ctyp
<:ctyp< [ > t ] >>TyVrnSup of Loc.t and ctyp
<:ctyp< [ < t ] >>TyVrnInf of Loc.t and ctyp
<:ctyp< [ < t > t ] >>TyVrnInfSup of Loc.t and ctyp and ctyp
<:ctyp< t & t >>TyAmp of Loc.t and ctyp and ctyp
<:ctyp< t of & t >>TyOfAmp of Loc.t and ctyp and ctyp
<:ctyp< $anti:s$ >>AntiquotationTyAnt of Loc.t and string

Patterns

QuotationSignificationAST
<:patt< >>Empty patternPaNil of Loc.t
<:patt< $id:i$ >>IdentifierPaId of Loc.t and ident
<:patt< p as p >>AliasPaAli of Loc.t and patt and patt
<:patt< $anti:s$ >>AntiquotationPaAnt of Loc.t and string
<:patt< _ >>WildcardPaAny of Loc.t
<:patt< p p >>ApplicationPaApp of Loc.t and patt and patt
<:patt< [| p |] >>ArrayPaArr of Loc.t and patt
<:patt< p, p >>Comma-separated pattern listPaCom of Loc.t and patt and patt
<:patt< p; p >>Semicolon-separated pattern listPaSem of Loc.t and patt and patt
<:patt< $chr:c$ >>CharacterPaChr of Loc.t and string
<:patt< $int:i$ >>IntegerPaInt of Loc.t and string
<:patt< $int32:i$ >>Int32PaInt32 of Loc.t and string
<:patt< $int64:i$ >>Int64PaInt64 of Loc.t and string
<:patt< $nativeint:i$ >>NativeIntPaNativeInt of Loc.t and string
<:patt< $flo:f$ >>FloatPaFlo of Loc.t and string
<:patt< ~s >> <:patt< s:(p) >>LabelPaLab of Loc.t and string and patt
<:patt< ?s >> <:patt< ?s:(p) >>Optional labelPaOlb of Loc.t and string and patt
<:patt< ?s:(p = e) >> <:patt< ?(p = e) >>Optional label with default valuePaOlbi of Loc.t and string and patt and expr
<:patt< p | p >>OrPaOrp of Loc.t and patt and patt
<:patt< p .. p >>Pattern rangePaRng of Loc.t and patt and patt
<:patt< { p } >>RecordPaRec of Loc.t and patt
<:patt< i = p >>EqualityPaEq of Loc.t and ident and patt
<:patt< $str:s$ >>StringPaStr of Loc.t and string
<:patt< ( p ) >>TuplePaTup of Loc.t and patt
<:patt< (p : t) >>Type constraintPaTyc of Loc.t and patt and ctyp
<:patt< #i >>PaTyp of Loc.t and ident
<:patt< `s >>Polymorphic variantPaVrn of Loc.t and string

Expressions

QuotationSignificationAST
<:expr< >>Empty expressionExNil of Loc.t
<:expr< $id:i$ >>IdentifierExId of Loc.t and ident
<:expr< e.e >>Access in moduleExAcc of Loc.t and expr and expr
<:expr< $anti:s$ >>AntiquotationExAnt of Loc.t and string
<:expr< e e >>ApplicationExApp of Loc.t and expr and expr
<:expr< e.(e) >>Array accessExAre of Loc.t and expr and expr
<:expr< [| e |] >>Array declarationExArr of Loc.t and expr
<:expr< e; e >>Semicolon-separated expression listExSem of Loc.t and expr and expr
<:expr< assert False >>assert FalseExAsf of Loc.t
<:expr< assert e >>assert eExAsr of Loc.t and expr
<:expr< e := e >>AssignmentExAss of Loc.t and expr and expr
<:expr< $chr:c$ >>CharacterExChr of Loc.t and string
<:expr< (e : t) >> <:expr< (e : t :> t) >>CoercionExCoe of Loc.t and expr and ctyp and ctyp
<:expr< $flo:f$ >>FloatExFlo of Loc.t and string
<:expr< for s = e to/downto e do { e } >>For loopExFor of Loc.t and string and expr and expr and meta_bool and expr
<:expr< fun [ a ] >>Function with match caseExFun of Loc.t and match_case
<:expr< if e then e else e >>if/then/elseExIfe of Loc.t and expr and expr and expr
<:expr< $int:i$ >>IntExInt of Loc.t and string
<:expr< $int32:i$ >>Int32ExInt32 of Loc.t and string
<:expr< $int64:i$ >>Int64ExInt64 of Loc.t and string
<:expr< $nativeint:i$ >>NativeIntExNativeInt of Loc.t and string
<:expr< ~s >> <:expr< ~s:e >>Label argument with/without expressionExLab of Loc.t and string and expr
<:expr< lazy e >>Lazy evaluationExLaz of Loc.t and expr
<:expr< let b in e >> <:expr< let rec b in e >>Let statement with/without recursionExLet of Loc.t and meta_bool and binding and expr
<:expr< let module s = me in e >>"Let module in" constructExLmd of Loc.t and string and module_expr and expr
<:expr< match e with [ a ] >>Match caseExMat of Loc.t and expr and match_case
<:expr< new $id:i$ >>New objectExNew of Loc.t and ident
<:expr< object ((p))? (cst)? end >>Object declarationExObj of Loc.t and patt and class_str_item
<:expr< ?s >> <:expr< ?s:e >>Optional labelExOlb of Loc.t and string and expr
<:expr< {< b >} >>OverloadingExOvr of Loc.t and rec_binding
<:expr< { b } >> <:expr< { (e) with b } >>RecordExRec of Loc.t and rec_binding and expr
<:expr< do { e } >>Sequence with "do" statementExSeq of Loc.t and expr
<:expr< e#s >>Method callExSnd of Loc.t and expr and string
<:expr< e.[e] >>String accessExSte of Loc.t and expr and expr
<:expr< $str:s$ >>StringExStr of Loc.t and string
<:expr< try e with [ a ] >>"Try .. with" constructExTry of Loc.t and expr and match_case
<:expr< (e) >>TupleExTup of Loc.t and expr
<:expr< e, e >>Comma-separated expression listExCom of Loc.t and expr and expr
<:expr< (e : t) >>Type constraintExTyc of Loc.t and expr and ctyp
<:expr< `s >>Polymorphic variantExVrn of Loc.t and string
<:expr< while e do { e } >>"While .. do" constraintExWhi of Loc.t and expr and expr

Module types

 module_type, mt ::=
   | (* empty *)
   | ident
   | functor (s : mt) -> mt
   | 's
   | sig sg end
   | mt with wc
   | $s$
 

Signature items

 sig_item, sg ::=
   | (* empty *)
   | class cict
   | class type cict
   | sg ; sg
   | #s
   | #s e
   | exception t
   | external s : t = s ... s
   | include mt
   | module s : mt
   | module rec mb
   | module type s = mt
   | open i
   | type t
   | value s : t
   | $s$
 

With constraints

 with_constraint, with_constr, wc ::=
   | wc and wc
   | type t = t
   | module i = i
 

Bindings

 binding, bi ::=
   | bi and bi
   | p = e
 

Record bindings

 record_binding, rec_binding, rb ::=
   | rb ; rb
   | x = e
 

Recursive module bindings

 module_binding, mb ::=
   | (* empty *)
   | mb and mb
   | s : mt = me
   | s : mt
   | $s$
 

Match cases

 match_case, mc ::=
   | (* empty *)
   | mc | mc
   | p when e -> e
   | p -> e           (* a sugar for << p when e1 -> e2 >> where e1 is the empty expression *)
 

Module expressions

 module_expression, module_expr, me ::=
   | (* empty *)
   | ident
   | me me
   | functor (s : mt) -> me
   | struct st end
   | (me : mt)
   | $s$
 

Structure items

 structure_item, str_item, st ::=
   | (* empty *)
   | class cice
   | class type cict
   | st ; st
   | #s
   | #s e
   | exception t or exception t = i
   | e
   | external s : t = s ... s
   | include me
   | module s = me
   | module rec mb
   | module type s = mt
   | open i
   | type t
   | value b or value rec bi
   | $s$
 

Class types

 class_type, ct ::=
   | (* empty *)
   | (virtual)? i ([ t ])?
   | [t] -> ct
   | object (t) csg end
   | ct and ct
   | ct : ct
   | ct = ct
   | $s$
 

Class signature items

 class_signature_item, class_sig_item, csg ::=
   | (* empty *)
   | type t = t
   | csg ; csg
   | inherit ct
   | method s : t or method private s : t
   | value (virtual)? (mutable)? s : t
   | method virtual (mutable)? s : t
   | $s$
 

Class expressions

 class_expression, class_expr, ce ::=
   | (* empty *)
   | ce e
   | (virtual)? i ([ t ])?
   | fun p -> ce
   | let (rec)? bi in ce
   | object (p) (cst) end
   | ce : ct
   | ce and ce
   | ce = ce
   | $s$
 

Class structure items

 class_structure_item, class_str_item, cst ::=
   | (* empty *)
   | cst ; cst
   | type t = t
   | inherit ce or inherit ce as s
   | initializer e
   | method (private)? s : t = e or method (private)? s = e
   | value (mutable)? s = e
   | method virtual (private)? s : t
   | value virtual (private)? s : t
   | $s$
Personal tools
Espace privé