Package net.hydromatic.morel.ast
Enum CoreBuilder
- All Implemented Interfaces:
Serializable,Comparable<CoreBuilder>,java.lang.constant.Constable
Builds parse tree nodes.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Core.WildcardPatprivate final Core.Literalprivate final Core.Literalprivate final Core.LiteralPat -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionandAlso(TypeSystem typeSystem, Iterable<Core.Exp> exps) Converts a list of 0 or more expressions into anandalso; simplifies empty list to "true" and singleton list "[e]" to "e".andAlso(TypeSystem typeSystem, Core.Exp a0, Core.Exp a1) Creates aCore.Apply.apply(Pos pos, TypeSystem typeSystem, BuiltIn builtIn, Core.Exp arg0, Core.Exp arg1, Core.Exp... args) Creates aCore.Applywith two or more arguments, packing the arguments into a tuple.private Core.ExpasPat(Type type, String name, NameGenerator nameGenerator, Core.Pat pat) Creates an AsPat with a given name, generating an ordinal to distinguish it from other declarations with the same name elsewhere in the program.boolLiteral(boolean b) Creates abooleanliteral.private static Core.LiteralboolLiteral_(boolean b) Used only during initialization.private Core.Applycall(TypeSystem typeSystem, BuiltIn builtIn, Core.Exp... args) Calls a built-in function.Calls a built-in function with one type parameter.charLiteral(char c) Creates acharliteral.datatypeDecl(Iterable<DataType> dataTypes) decomposeAnd(Core.Exp exp) Decomposes anandalsoexpression; inverse ofandAlso(TypeSystem, Iterable).decomposeOr(Core.Exp exp) Decomposes anorelseexpression; inverse oforElse(TypeSystem, Iterable).elem(TypeSystem typeSystem, Core.Exp a0, Core.Exp a1) equal(TypeSystem typeSystem, Core.Exp a0, Core.Exp a1) extent(TypeSystem typeSystem, Type type, com.google.common.collect.RangeSet rangeSet) Creates an extent.extent(TypeSystem typeSystem, Type type, Map<String, com.google.common.collect.ImmutableRangeSet> rangeSetMap) field(TypeSystem typeSystem, Core.Exp exp, int slot) Creates a reference to theslotth field of an expression, "#slot exp".voidflattenAnd(Core.Exp exp, Consumer<Core.Exp> consumer) Flattens theandalsos in an expression into a consumer.voidflattenAnds(List<Core.Exp> exps, Consumer<Core.Exp> consumer) Flattens theandalsos in every expression into a consumer.voidFlattens theorelses in an expression into a consumer.voidflattenOrs(List<Core.Exp> exps, Consumer<Core.Exp> consumer) Flattens theorelses in every expression into a consumer.fn(Pos pos, FnType type, List<Core.Match> matchList, NameGenerator nameGenerator) fn(FnType type, Core.IdPat idPat, Core.Exp exp) private <E> EfoldRight(List<E> list, BiFunction<E, E, E> fold) from(ListType type, List<Core.FromStep> steps) from(TypeSystem typeSystem, List<Core.FromStep> steps) Derives the result type, then callsfrom(ListType, List).fromBuilder(TypeSystem typeSystem) Creates a builder that will create aCore.Frombut does not validate.fromBuilder(TypeSystem typeSystem, @Nullable Environment env) Creates a builder that will create aCore.From.private TypefromElementType(TypeSystem typeSystem, List<Core.FromStep> steps) Returns the element type of aCore.Fromwith the given steps.functionLiteral(TypeSystem typeSystem, BuiltIn builtIn) Creates a function literal.greaterThan(TypeSystem typeSystem, Core.Exp a0, Core.Exp a1) greaterThanOrEqualTo(TypeSystem typeSystem, Core.Exp a0, Core.Exp a1) group(SortedMap<Core.IdPat, Core.Exp> groupExps, SortedMap<Core.IdPat, Core.Aggregate> aggregates) id(Core.NamedPat idPat) Creates a reference to a value.Creates an IdPat with a given name and ordinal.idPat(Type type, String name, NameGenerator nameGenerator) Creates an IdPat with a given name, generating an ordinal to distinguish it from other declarations with the same name elsewhere in the program.idPat(Type type, NameGenerator nameGenerator) Creates an IdPat with a system-generated unique name.ifThenElse(Core.Exp condition, Core.Exp ifTrue, Core.Exp ifFalse) implicitYieldExp(TypeSystem typeSystem, List<Core.FromStep> steps) Returns what would be the yield expression if we created aCore.Fromfrom the given steps.internalLiteral(Object value) Creates an internal literal.intersect(TypeSystem typeSystem, Iterable<Core.Exp> exps) intersect(TypeSystem typeSystem, Core.Exp a0, Core.Exp a1) intersectExtents(TypeSystem typeSystem, List<? extends Core.Exp> exps) intLiteral(BigDecimal value) Creates anintliteral.lastBindings(List<? extends Core.FromStep> steps) lessThan(TypeSystem typeSystem, Core.Exp a0, Core.Exp a1) let(Core.ValDecl decl, Core.Exp exp) list(TypeSystem typeSystem, Core.Exp arg0, Core.Exp... args) Creates a list with one or more elements.list(TypeSystem typeSystem, Type elementType, List<Core.Exp> args) Creates a list.listPat(TypeSystem typeSystem, List<Core.Pat> args) literal(PrimitiveType type, Object value) Creates a literal.literalPat(Op op, Type type, Comparable value) nonRecValDecl(Pos pos, Core.NamedPat pat, Core.Exp exp) notEqual(TypeSystem typeSystem, Core.Exp a0, Core.Exp a1) only(TypeSystem typeSystem, Pos pos, Core.Exp a0) order(List<Binding> bindings, Iterable<Core.OrderItem> orderItems) orderItem(Core.Exp exp, Ast.Direction direction) orElse(TypeSystem typeSystem, Iterable<Core.Exp> exps) Converts a list of 0 or more expressions into anorelse; simplifies empty list to "false" and singleton list "[e]" to "e".orElse(TypeSystem typeSystem, Core.Exp a0, Core.Exp a1) realLiteral(Float value) Creates afloatliteral with a non-normal value.realLiteral(BigDecimal value) Creates afloatliteral.record(TypeSystem typeSystem, Collection<? extends Map.Entry<String, ? extends Core.Exp>> nameExps) Creates a record from a collection of named expressions.record(TypeSystem typeSystem, Map<String, ? extends Core.Exp> nameExps) Creates a record from a map of named expressions.private Core.Tuplerecord_(TypeSystem typeSystem, com.google.common.collect.ImmutableSortedMap<String, Core.Exp> nameExps) recordPat(RecordType type, List<? extends Core.Pat> args) recordSelector(FnType fnType, int slot) recordSelector(TypeSystem typeSystem, RecordLikeType recordType, int slot) recordSelector(TypeSystem typeSystem, RecordLikeType recordType, String fieldName) recValDecl(Iterable<? extends Core.NonRecValDecl> list) simplify(TypeSystem typeSystem, Core.Exp exp) Simplifies an expression.stringLiteral(String value) Creates a string literal.subTrue(TypeSystem typeSystem, Core.Exp exp, List<Core.Exp> trueExps) Returns an expression substituting every given expression as true.tuple(RecordLikeType type, Iterable<? extends Core.Exp> args) tuple(RecordLikeType type, Core.Exp... args) tuple(TypeSystem typeSystem, Core.Exp... args) tuple(TypeSystem typeSystem, @Nullable RecordLikeType type, Iterable<? extends Core.Exp> args) Astuple(RecordLikeType, Iterable), but derives type.tuplePat(RecordLikeType type, Iterable<? extends Core.Pat> args) tuplePat(RecordLikeType type, Core.Pat... args) tuplePat(TypeSystem typeSystem, List<Core.Pat> args) union(TypeSystem typeSystem, Iterable<Core.Exp> exps) union(TypeSystem typeSystem, Core.Exp a0, Core.Exp a1) unionExtents(TypeSystem typeSystem, List<? extends Core.Exp> exps) Creates a unit literal.valueLiteral(Core.Exp exp, Object value) Creates a value literal.static CoreBuilderReturns the enum constant of this type with the specified name.static CoreBuilder[]values()Returns an array containing the constants of this enum type, in the order they are declared.wildcardPat(Type type) yield_(TypeSystem typeSystem, Core.Exp exp) Derives bindings, then callsyield_(List, Core.Exp).
-
Enum Constant Details
-
core
The singleton instance of the CORE builder. The short name is convenient for use via 'import static', but checkstyle does not approve.
-
-
Field Details
-
truePat
-
boolWildcardPat
-
trueLiteral
-
falseLiteral
-
-
Constructor Details
-
CoreBuilder
private CoreBuilder()
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
literal
Creates a literal. -
boolLiteral_
Used only during initialization. -
boolLiteral
Creates abooleanliteral. -
charLiteral
Creates acharliteral. -
intLiteral
Creates anintliteral. -
realLiteral
Creates afloatliteral. -
realLiteral
Creates afloatliteral with a non-normal value. -
stringLiteral
Creates a string literal. -
unitLiteral
Creates a unit literal. -
functionLiteral
Creates a function literal. -
valueLiteral
Creates a value literal. -
internalLiteral
Creates an internal literal. -
id
Creates a reference to a value. -
recordSelector
public Core.RecordSelector recordSelector(TypeSystem typeSystem, RecordLikeType recordType, String fieldName) -
recordSelector
public Core.RecordSelector recordSelector(TypeSystem typeSystem, RecordLikeType recordType, int slot) -
recordSelector
-
idPat
Creates an IdPat with a given name and ordinal. You must ensure that the ordinal is unique for this name in this program. -
idPat
Creates an IdPat with a system-generated unique name. -
idPat
Creates an IdPat with a given name, generating an ordinal to distinguish it from other declarations with the same name elsewhere in the program. -
literalPat
-
wildcardPat
-
asPat
-
asPat
Creates an AsPat with a given name, generating an ordinal to distinguish it from other declarations with the same name elsewhere in the program. -
consPat
-
conPat
-
con0Pat
-
tuplePat
-
tuplePat
-
tuplePat
-
listPat
-
listPat
-
listPat
-
recordPat
-
recordPat
-
tuple
-
tuple
-
tuple
-
tuple
public Core.Tuple tuple(TypeSystem typeSystem, @Nullable RecordLikeType type, Iterable<? extends Core.Exp> args) Astuple(RecordLikeType, Iterable), but derives type.If present,
typeserves as a template, dictating whether to produce a record or a tuple type, and if a record type, the field names. If not present, the result is a tuple type. -
let
-
local
-
nonRecValDecl
-
recValDecl
-
match
-
caseOf
-
from
-
from
Derives the result type, then callsfrom(ListType, List). -
fromElementType
Returns the element type of aCore.Fromwith the given steps. -
implicitYieldExp
-
lastBindings
-
fromBuilder
Creates a builder that will create aCore.From. -
fromBuilder
Creates a builder that will create aCore.Frombut does not validate. -
fn
-
fn
-
apply
Creates aCore.Apply. -
apply
public Core.Apply apply(Pos pos, TypeSystem typeSystem, BuiltIn builtIn, Core.Exp arg0, Core.Exp arg1, Core.Exp... args) Creates aCore.Applywith two or more arguments, packing the arguments into a tuple. -
ifThenElse
-
datatypeDecl
-
scan
-
aggregate
-
order
-
orderItem
-
group
public Core.Group group(SortedMap<Core.IdPat, Core.Exp> groupExps, SortedMap<Core.IdPat, Core.Aggregate> aggregates) -
where
-
skip
-
take
-
yield_
-
yield_
Derives bindings, then callsyield_(List, Core.Exp). -
field
Creates a reference to theslotth field of an expression, "#slot exp". The expression's type must be record or tuple. -
list
Creates a list. -
list
Creates a list with one or more elements. -
extent
public Core.Exp extent(TypeSystem typeSystem, Type type, com.google.common.collect.RangeSet rangeSet) Creates an extent. It returns a list of all values of a given type that fall into a given range-set. The range-set might consist of justRange.all(), in which case, the list returns all values of the type. -
extent
public Core.Exp extent(TypeSystem typeSystem, Type type, Map<String, com.google.common.collect.ImmutableRangeSet> rangeSetMap) -
intersectExtents
-
unionExtents
-
simplify
Simplifies an expression.In particular, it merges extents. For example,
becomesextent "[10, 20]" orelse (extent "[-inf,5]" andalso "[1,int]")extent "[[1, 5], [10, 20]]" -
record
Creates a record from a map of named expressions. -
record
public Core.Exp record(TypeSystem typeSystem, Collection<? extends Map.Entry<String, ? extends Core.Exp>> nameExps) Creates a record from a collection of named expressions. -
record_
private Core.Tuple record_(TypeSystem typeSystem, com.google.common.collect.ImmutableSortedMap<String, Core.Exp> nameExps) -
call
Calls a built-in function. -
call
public Core.Apply call(TypeSystem typeSystem, BuiltIn builtIn, Type type, Pos pos, Core.Exp... args) Calls a built-in function with one type parameter. -
args
-
equal
-
notEqual
-
lessThan
-
greaterThan
-
greaterThanOrEqualTo
-
elem
-
andAlso
-
andAlso
Converts a list of 0 or more expressions into anandalso; simplifies empty list to "true" and singleton list "[e]" to "e". -
orElse
-
orElse
Converts a list of 0 or more expressions into anorelse; simplifies empty list to "false" and singleton list "[e]" to "e". -
foldRight
-
only
-
union
-
union
-
intersect
-
intersect
-
subTrue
Returns an expression substituting every given expression as true.For example, if
expis "x = 1 andalso y > 2" andtrueExpsis [x = 1,z = 2], returns "y > 2". -
decomposeAnd
Decomposes anandalsoexpression; inverse ofandAlso(TypeSystem, Iterable).Examples:
- "p1 andalso p2" becomes "[p1, p2]" (two elements);
- "p1 andalso p2 andalso p3" becomes "[p1, p2, p3]" (three elements);
- "p1 orelse p2" becomes "[p1 orelse p2]" (one element);
- "true" becomes "[]" (no elements);
- "false" becomes "[false]" (one element).
-
decomposeOr
Decomposes anorelseexpression; inverse oforElse(TypeSystem, Iterable).Examples:
- "p1 orelse p2" becomes "[p1, p2]" (two elements);
- "p1 orelse p2 orelse p3" becomes "[p1, p2, p3]" (three elements);
- "p1 andalso p2" becomes "[p1 andalso p2]" (one element);
- "false" becomes "[]" (no elements);
- "true" becomes "[true]" (one element).
-
flattenAnd
Flattens theandalsos in an expression into a consumer. -
flattenAnds
Flattens theandalsos in every expression into a consumer. -
flattenOr
Flattens theorelses in an expression into a consumer. -
flattenOrs
Flattens theorelses in every expression into a consumer.
-