diff --git a/gen/midas.py b/gen/midas.py index fb90199..423d16b 100644 --- a/gen/midas.py +++ b/gen/midas.py @@ -136,15 +136,6 @@ class ConstraintType: constraint: Expr -class ComplexType: - members: list[MemberStmt] - - -class ExtensionType: - base: Type - extension: ComplexType - - class FunctionType: params: ParamSpec returns: Type diff --git a/midas/ast/midas.py b/midas/ast/midas.py index eae434a..2a822e5 100644 --- a/midas/ast/midas.py +++ b/midas/ast/midas.py @@ -256,12 +256,6 @@ class Type(ABC): @abstractmethod def visit_constraint_type(self, type: ConstraintType) -> T: ... - @abstractmethod - def visit_complex_type(self, type: ComplexType) -> T: ... - - @abstractmethod - def visit_extension_type(self, type: ExtensionType) -> T: ... - @abstractmethod def visit_function_type(self, type: FunctionType) -> T: ... @@ -295,23 +289,6 @@ class ConstraintType(Type): return visitor.visit_constraint_type(self) -@dataclass(frozen=True) -class ComplexType(Type): - members: list[MemberStmt] - - def accept(self, visitor: Type.Visitor[T]) -> T: - return visitor.visit_complex_type(self) - - -@dataclass(frozen=True) -class ExtensionType(Type): - base: Type - extension: ComplexType - - def accept(self, visitor: Type.Visitor[T]) -> T: - return visitor.visit_extension_type(self) - - @dataclass(frozen=True) class FunctionType(Type): params: ParamSpec diff --git a/midas/ast/printer/midas.py b/midas/ast/printer/midas.py index cbb62d7..56d7ce8 100644 --- a/midas/ast/printer/midas.py +++ b/midas/ast/printer/midas.py @@ -124,19 +124,6 @@ class MidasPrinter( res += " where " + type.constraint.accept(self) return res - def visit_complex_type(self, type: m.ComplexType) -> str: - res: str = "{\n" - self.level += 1 - for member in type.members: - res += member.accept(self) - res += "\n" - self.level -= 1 - res += self.indented("}") - return res - - def visit_extension_type(self, type: m.ExtensionType) -> str: - return f"{type.base.accept(self)} & {type.extension.accept(self)}" - def visit_function_type(self, type: m.FunctionType) -> str: spec: str = self._visit_param_spec(type.params) return f"fn {spec} -> {type.returns.accept(self)}" diff --git a/midas/ast/printer/midas_ast.py b/midas/ast/printer/midas_ast.py index 69a0b16..d2e5daf 100644 --- a/midas/ast/printer/midas_ast.py +++ b/midas/ast/printer/midas_ast.py @@ -177,21 +177,6 @@ class MidasAstPrinter( with self._child_level(single=True): type.constraint.accept(self) - def visit_complex_type(self, type: m.ComplexType) -> None: - self._write_line("ComplexType") - with self._child_level(): - self._write_sequence("members", type.members, last=True) - - def visit_extension_type(self, type: m.ExtensionType) -> None: - self._write_line("ExtensionType") - with self._child_level(): - self._write_line("base") - with self._child_level(single=True): - type.base.accept(self) - self._write_line("extension", last=True) - with self._child_level(single=True): - type.extension.accept(self) - def visit_function_type(self, type: m.FunctionType) -> None: self._write_line("FunctionType") with self._child_level(): diff --git a/midas/checker/midas.py b/midas/checker/midas.py index e8cf791..02eb547 100644 --- a/midas/checker/midas.py +++ b/midas/checker/midas.py @@ -13,11 +13,9 @@ from midas.checker.registry import TypesRegistry from midas.checker.reporter import FileReporter, Reporter from midas.checker.types import ( ColumnType, - ComplexType, ConstraintType, DataFrameType, DerivedType, - ExtensionType, Function, GenericType, ParamSpec, @@ -422,19 +420,6 @@ class MidasTyper(m.Stmt.Visitor[None], m.Expr.Visitor[Type], m.Type.Visitor[Type constraint=type.constraint, ) - def visit_complex_type(self, type: m.ComplexType) -> ComplexType: - return ComplexType( - members={ - member.name.lexeme: member.type.accept(self) for member in type.members - } - ) - - def visit_extension_type(self, type: m.ExtensionType) -> Type: - return ExtensionType( - base=type.base.accept(self), - extension=self.visit_complex_type(type.extension), - ) - def visit_function_type(self, type: m.FunctionType) -> Type: return Function( params=self._visit_param_spec(type.params), diff --git a/midas/checker/registry.py b/midas/checker/registry.py index c30c5e4..0c97074 100644 --- a/midas/checker/registry.py +++ b/midas/checker/registry.py @@ -8,11 +8,9 @@ from midas.checker.types import ( AppliedType, BaseType, ColumnType, - ComplexType, ConstraintType, DataFrameType, DerivedType, - ExtensionType, Function, GenericType, OverloadedFunction, @@ -202,14 +200,6 @@ class TypesRegistry: case (BaseType(name=name1), BaseType(name=name2)): return self.is_builtin_subtype(name1, name2) - case (ComplexType(properties=props1), ComplexType(properties=props2)): - for k, t in props2.items(): - if k not in props1: - return False - if not self.is_subtype(props1[k], t): - return False - return True - case (DataFrameType(columns=columns1), DataFrameType(columns=columns2)): # TODO: check order? by_name1: dict[str, DataFrameType.Column] = { @@ -506,20 +496,6 @@ class TypesRegistry: member_type2 = substitute_typevars(member_type2, substitutions) return member_type2 - case ComplexType(members=members): - if member_name in members: - return members[member_name] - self.logger.debug(f"No member '{member_name}' in {type}") - return None - - case ExtensionType(base=base, extension=ComplexType(members=members)): - if member_name in members: - return members[member_name] - self.logger.debug( - f"No member '{member_name}' on {type}, looking up in base" - ) - return self.lookup_member(base, member_name) - case ConstraintType(type=base): return self.lookup_member(base, member_name) diff --git a/midas/checker/types.py b/midas/checker/types.py index 5b043bc..ae56374 100644 --- a/midas/checker/types.py +++ b/midas/checker/types.py @@ -113,28 +113,6 @@ class OverloadedFunction: return "" -@dataclass(frozen=True, kw_only=True) -class ComplexType: - """A type with inline members""" - - members: dict[str, Type] - - def __str__(self) -> str: - props: list[str] = [f"{name}: {type}" for name, type in self.members.items()] - return f"{{{', '.join(props)}}}" - - -@dataclass(frozen=True, kw_only=True) -class ExtensionType: - """An extension of a type, adding members through a `ComplexType`""" - - base: Type - extension: ComplexType - - def __str__(self) -> str: - return f"{self.base} & {self.extension}" - - class Variance(StrEnum): """The variance of a :class:`TypeVar`""" @@ -323,24 +301,6 @@ def substitute_typevars(type: Type, substitutions: dict[str, Type]) -> Type: ] ) - case ComplexType(members=members): - members2: dict[str, Type] = { - name: substitute_typevars(prop, substitutions) - for name, prop in members.items() - } - return ComplexType(members=members2) - - case ExtensionType(base=base, extension=ComplexType(members=members)): - return ExtensionType( - base=substitute_typevars(base, substitutions), - extension=ComplexType( - members={ - name: substitute_typevars(prop, substitutions) - for name, prop in members.items() - } - ), - ) - case AppliedType(name=name, args=args, body=body): return AppliedType( name=name, @@ -468,9 +428,6 @@ def to_annotation(type: Type) -> str: case OverloadedFunction(): return "Callable" - case ComplexType() | ExtensionType(): - raise NotImplementedError - case TypeVar(name=name): return name @@ -519,8 +476,6 @@ Type = ( | UnitType | Function | OverloadedFunction - | ComplexType - | ExtensionType | TypeVar | GenericType | AppliedType diff --git a/midas/cli/highlighter.py b/midas/cli/highlighter.py index 15f3251..2db4637 100644 --- a/midas/cli/highlighter.py +++ b/midas/cli/highlighter.py @@ -338,21 +338,11 @@ class MidasHighlighter( type.type.accept(self) type.constraint.accept(self) - def visit_complex_type(self, type: m.ComplexType) -> None: - self.wrap(type, "complex-type") - for member in type.members: - member.accept(self) - def visit_function_type(self, type: m.FunctionType) -> None: self.wrap(type, "function") self._visit_param_spec(type.params) type.returns.accept(self) - def visit_extension_type(self, type: m.ExtensionType) -> None: - self.wrap(type, "extension") - type.base.accept(self) - type.extension.accept(self) - def _visit_param_spec(self, spec: m.ParamSpec) -> None: for param in spec.pos + spec.mixed + spec.kw: param.type.accept(self) diff --git a/midas/cli/hl_midas.css b/midas/cli/hl_midas.css index fabb84e..3580132 100644 --- a/midas/cli/hl_midas.css +++ b/midas/cli/hl_midas.css @@ -7,8 +7,7 @@ span { &.named-type, &.generic-type, - &.constraint-type, - &.complex-type { + &.constraint-type { --col: 150, 150, 150; } diff --git a/midas/generator/generator.py b/midas/generator/generator.py index 35634a5..18885a4 100644 --- a/midas/generator/generator.py +++ b/midas/generator/generator.py @@ -16,11 +16,9 @@ from midas.checker.types import ( BaseType, ColumnGroupBy, ColumnType, - ComplexType, ConstraintType, DataFrameType, DerivedType, - ExtensionType, FrameGroupBy, Function, GenericType, @@ -675,8 +673,6 @@ class Generator(p.Stmt.Visitor[ast.stmt], p.Expr.Visitor[ast.expr]): case ( Function() | OverloadedFunction() - | ComplexType() - | ExtensionType() | GenericType() | FrameGroupBy() | ColumnGroupBy() diff --git a/midas/generator/stubs.py b/midas/generator/stubs.py index f185f97..b228916 100644 --- a/midas/generator/stubs.py +++ b/midas/generator/stubs.py @@ -8,11 +8,9 @@ from midas.checker.types import ( BaseType, ColumnGroupBy, ColumnType, - ComplexType, ConstraintType, DataFrameType, DerivedType, - ExtensionType, FrameGroupBy, Function, GenericType, @@ -269,14 +267,6 @@ class StubsGenerator: right=self.dump_type(overloads[-1]), ) - case ComplexType(): - name: str = self.new_stub_name() - self.generate_stub(name, type) - return ast.Name(id=name) - - case ExtensionType(): - raise NotImplementedError - case TypeVar(): return ast.Name(id=type.name) diff --git a/midas/parser/midas.py b/midas/parser/midas.py index 6678dbc..fef0e97 100644 --- a/midas/parser/midas.py +++ b/midas/parser/midas.py @@ -5,11 +5,9 @@ from midas.ast.midas import ( AliasStmt, BinaryExpr, CallExpr, - ComplexType, ConstraintType, Expr, ExtendStmt, - ExtensionType, FrameType, FunctionType, GenericType, @@ -187,19 +185,9 @@ class MidasParser(Parser[list[Stmt]]): Returns: TypeExpr: the parsed type expression """ - base: Type if self.match(TokenType.FUNC): - base = self.function() - else: - base = self.constraint_type() - if self.match(TokenType.AND): - extension: ComplexType = self.complex_type() - return ExtensionType( - location=Location.span(base.location, extension.location), - base=base, - extension=extension, - ) - return base + return self.function() + return self.constraint_type() def constraint_type(self) -> Type: """Parse a constraint type expression @@ -235,9 +223,6 @@ class MidasParser(Parser[list[Stmt]]): self.consume(TokenType.RIGHT_PAREN, "Unclosed parenthesis") return type - if self.check(TokenType.LEFT_BRACE): - return self.complex_type() - return self.generic_type() def generic_type(self) -> Type: @@ -295,34 +280,6 @@ class MidasParser(Parser[list[Stmt]]): name=name, ) - def complex_type(self) -> ComplexType: - """Parse a complex type expression - - A complex type consists of zero or more member statements enclosed in - curly braces - - Returns: - ComplexType: the parsed complex type expression - """ - left: Token = self.consume( - TokenType.LEFT_BRACE, "Expected '{' to start type body" - ) - members: list[MemberStmt] = [] - # TODO: add keyword to differentiate properties and methods, - # and allow multiple methods with the same name but not properties - names: set[str] = set() - while not self.check(TokenType.RIGHT_BRACE) and not self.is_at_end(): - member: MemberStmt = self.member_stmt() - # if member.name.lexeme in names: - # raise self.error(member.name, "Duplicate property") - # names.add(member.name.lexeme) - members.append(member) - right: Token = self.consume(TokenType.RIGHT_BRACE, "Unclosed type body") - return ComplexType( - location=left.location_to(right), - members=members, - ) - def frame_type(self) -> FrameType: """Parse a frame type expression diff --git a/syntax/midas.ebnf b/syntax/midas.ebnf index a2bf9de..1caa366 100644 --- a/syntax/midas.ebnf +++ b/syntax/midas.ebnf @@ -66,15 +66,13 @@ Params ::= ( ) ParamSpec ::= "(" Params? ")" -TypeProperty ::= Identifier ":" Type -ComplexType ::= "{" TypeProperty* "}" NamedType ::= Identifier TypeArgs ::= "[" (Type ("," Type)*)? "]" FrameColumn ::= TOKEN ":" Type FrameSchema ::= "[" (FrameColumn ("," FrameColumn)*)? "]" GenericType ::= "Frame" FrameSchema | NamedType TypeArgs? GroupedType ::= "(" Type ")" -BaseType ::= GroupedType | ComplexType | GenericType +BaseType ::= GroupedType | GenericType ConstraintType ::= BaseType ("where" Constraint)? FuncType ::= "fn" ParamSpec "->" Type Type ::= ConstraintType diff --git a/syntax/midas.typ b/syntax/midas.typ index 736d0a3..9d8d805 100644 --- a/syntax/midas.typ +++ b/syntax/midas.typ @@ -72,14 +72,6 @@ svg.railroad .terminal rect { {[`template` "[" "]"]} ``` -#let type-property = ``` -{[`type-property` 'identifier' ":" 'type']} -``` - -#let complex-type = ``` -{[`complex-type` "{" "}"]} -``` - #let named-type = ``` {[`named-type` 'identifier']} ``` @@ -101,7 +93,7 @@ svg.railroad .terminal rect { ``` #let base-type = ``` -{[`base-type` <'grouped-type', 'complex-type', 'generic-type'>]} +{[`base-type` <'grouped-type', 'generic-type'>]} ``` #let constraint-type = ``` @@ -169,7 +161,6 @@ svg.railroad .terminal rect { template-param: template-param, template: template, type-property: type-property, - complex-type: complex-type, named-type: named-type, type-args: type-args, generic-type: generic-type, @@ -196,7 +187,6 @@ svg.railroad .terminal rect { "template", "type-property", "call-args", - "complex-type", "type-args", "named-type", "grouped-type", diff --git a/tests/cases/checker/09_frame_ops.py b/tests/cases/checker/09_frame_ops.py index 6d478f6..908f4ba 100644 --- a/tests/cases/checker/09_frame_ops.py +++ b/tests/cases/checker/09_frame_ops.py @@ -1,8 +1,8 @@ # type: ignore # ruff: disable [F821] -df1: Frame[a:int, b:float] -df2: Frame[a:int, b:float] +df1: Frame[i:int, a:int, b:float] +df2: Frame[i:int, a:int, b:float] _: Any @@ -38,7 +38,7 @@ _ = df1.sum() _ = df1.var() # Groupby -df_gb = df1.groupby(by="a") +df_gb = df1.groupby(by="i") _ = df_gb.kurt() _ = df_gb.max() diff --git a/tests/cases/checker/09_frame_ops.py.ref.json b/tests/cases/checker/09_frame_ops.py.ref.json index dd689df..189640b 100644 --- a/tests/cases/checker/09_frame_ops.py.ref.json +++ b/tests/cases/checker/09_frame_ops.py.ref.json @@ -14,7 +14,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -23,6 +23,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -46,7 +55,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -55,6 +64,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -86,7 +104,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -95,6 +113,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -118,7 +145,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -127,6 +154,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -150,7 +186,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -159,6 +195,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -190,7 +235,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -199,6 +244,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -222,7 +276,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -231,6 +285,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -254,7 +317,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -263,6 +326,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -294,7 +366,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -303,6 +375,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -326,7 +407,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -335,6 +416,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -358,7 +448,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -367,6 +457,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -398,7 +497,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "float" @@ -407,6 +506,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "float" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -430,7 +538,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -439,6 +547,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -462,7 +579,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -471,6 +588,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -502,7 +628,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -511,6 +637,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -534,7 +669,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -543,6 +678,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -566,7 +710,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -575,6 +719,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -606,7 +759,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -615,6 +768,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -638,7 +800,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -647,6 +809,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -670,7 +841,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -679,6 +850,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -710,7 +890,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -719,6 +899,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": {} @@ -740,7 +929,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -749,6 +938,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -772,7 +970,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -781,6 +979,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -812,7 +1019,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "bool" @@ -821,6 +1028,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "bool" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -844,7 +1060,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -853,6 +1069,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -876,7 +1101,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -885,6 +1110,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -916,7 +1150,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "bool" @@ -925,6 +1159,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "bool" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -948,7 +1191,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -957,6 +1200,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -980,7 +1232,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -989,6 +1241,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -1020,7 +1281,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "bool" @@ -1029,6 +1290,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "bool" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -1052,7 +1322,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -1061,6 +1331,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -1084,7 +1363,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -1093,6 +1372,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -1124,7 +1412,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "bool" @@ -1133,6 +1421,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "bool" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -1156,7 +1453,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -1165,6 +1462,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -1188,7 +1494,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -1197,6 +1503,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -1228,7 +1543,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "bool" @@ -1237,6 +1552,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "bool" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -1260,7 +1584,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -1269,6 +1593,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -1292,7 +1625,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -1301,6 +1634,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -1332,7 +1674,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "bool" @@ -1341,6 +1683,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "bool" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -1364,7 +1715,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -1373,6 +1724,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -1418,7 +1778,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -1427,6 +1787,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -1472,7 +1841,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -1481,6 +1850,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -1526,7 +1904,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -1535,6 +1913,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -1580,7 +1967,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -1589,6 +1976,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -1634,7 +2030,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -1643,6 +2039,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -1688,7 +2093,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -1697,6 +2102,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -1742,7 +2156,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -1751,6 +2165,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -1796,7 +2219,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -1805,6 +2228,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -1850,7 +2282,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -1859,6 +2291,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -1904,7 +2345,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -1913,6 +2354,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -1958,7 +2408,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -1967,6 +2417,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -2006,7 +2465,7 @@ }, "expr": { "_type": "LiteralExpr", - "value": "a" + "value": "i" }, "type": { "name": "str" @@ -2025,7 +2484,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -2034,6 +2493,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -2063,7 +2531,7 @@ "keywords": { "by": { "_type": "LiteralExpr", - "value": "a" + "value": "i" } } }, @@ -2768,7 +3236,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -2777,6 +3245,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -2822,7 +3299,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -2831,6 +3308,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -4447,7 +4933,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -4456,6 +4942,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -4496,7 +4991,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -4505,6 +5000,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -4545,7 +5049,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -4554,6 +5058,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -4735,7 +5248,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -4744,6 +5257,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -4776,7 +5298,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -4785,6 +5307,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -4808,7 +5339,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -4817,6 +5348,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { @@ -4849,7 +5389,7 @@ "columns": [ { "index": 0, - "name": "a", + "name": "i", "type": { "type": { "name": "int" @@ -4858,6 +5398,15 @@ }, { "index": 1, + "name": "a", + "type": { + "type": { + "name": "int" + } + } + }, + { + "index": 2, "name": "b", "type": { "type": { diff --git a/tests/cases/midas-parser/01_simple_types.midas b/tests/cases/midas-parser/01_simple_types.midas index f0df3e2..3b982e1 100644 --- a/tests/cases/midas-parser/01_simple_types.midas +++ b/tests/cases/midas-parser/01_simple_types.midas @@ -9,26 +9,22 @@ type Longitude = float where (-180 <= _ <= 180) type Difference[T] = T // Complex custom type, containing two values accessible through properties -type GeoLocation = { +type GeoLocation = object + +extend GeoLocation { prop lat: Latitude prop lon: Longitude } -// Define operations on our custom type -extend GeoLocation { - // This type is compatible with the `-` operation with another GeoLocation - // i.e. you can subtract a GeoLocation from another GeoLocation, resulting - // in a Difference of GeoLocations - def __sub__: fn(GeoLocation, /) -> Difference[GeoLocation] -} +type GeoLocationDifference = object -// For complex generics, you need to specify how the genericity the properties -// are handled -type Difference[GeoLocation] = { +extend GeoLocationDifference { prop lat: Difference[Latitude] prop lon: Difference[Longitude] } +// Define operations on our custom type + // Simple operation defined on our custom types extend Latitude { def __sub__: fn(Latitude, /) -> Difference[Latitude] @@ -38,13 +34,23 @@ extend Longitude { def __sub__: fn(Longitude, /) -> Difference[Longitude] } +extend GeoLocation { + // This type is compatible with the `-` operation with another GeoLocation + // i.e. you can subtract a GeoLocation from another GeoLocation, resulting + // in a GeoLocationDifference + def __sub__: fn(GeoLocation, /) -> GeoLocationDifference +} + + // Predefined custom predicates that can be referenced in other definitions predicate Positive(v: float) = v >= 0 predicate StrictlyPositive(v: float) = v > 0 predicate Equatorial(loc: GeoLocation) = (-10 <= loc.lat <= 10) predicate Arctic(loc: GeoLocation) = (loc.lat >= 66) -type Person = { +type Person = object + +extend Person { prop name: str // Property with an inline constraint diff --git a/tests/cases/midas-parser/01_simple_types.midas.ref.json b/tests/cases/midas-parser/01_simple_types.midas.ref.json index a49265b..62936de 100644 --- a/tests/cases/midas-parser/01_simple_types.midas.ref.json +++ b/tests/cases/midas-parser/01_simple_types.midas.ref.json @@ -493,8 +493,8 @@ "column": 19 }, { - "type": "LEFT_BRACE", - "lexeme": "{", + "type": "IDENTIFIER", + "lexeme": "object", "line": 12, "column": 20 }, @@ -502,620 +502,614 @@ "type": "NEWLINE", "lexeme": "\n", "line": 12, - "column": 21 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 13, - "column": 1 - }, - { - "type": "PROP", - "lexeme": "prop", - "line": 13, - "column": 5 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 13, - "column": 9 - }, - { - "type": "IDENTIFIER", - "lexeme": "lat", - "line": 13, - "column": 10 - }, - { - "type": "COLON", - "lexeme": ":", - "line": 13, - "column": 13 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 13, - "column": 14 - }, - { - "type": "IDENTIFIER", - "lexeme": "Latitude", - "line": 13, - "column": 15 + "column": 26 }, { "type": "NEWLINE", "lexeme": "\n", "line": 13, - "column": 23 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 14, "column": 1 }, - { - "type": "PROP", - "lexeme": "prop", - "line": 14, - "column": 5 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 14, - "column": 9 - }, - { - "type": "IDENTIFIER", - "lexeme": "lon", - "line": 14, - "column": 10 - }, - { - "type": "COLON", - "lexeme": ":", - "line": 14, - "column": 13 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 14, - "column": 14 - }, - { - "type": "IDENTIFIER", - "lexeme": "Longitude", - "line": 14, - "column": 15 - }, - { - "type": "NEWLINE", - "lexeme": "\n", - "line": 14, - "column": 24 - }, - { - "type": "RIGHT_BRACE", - "lexeme": "}", - "line": 15, - "column": 1 - }, - { - "type": "NEWLINE", - "lexeme": "\n", - "line": 15, - "column": 2 - }, - { - "type": "NEWLINE", - "lexeme": "\n", - "line": 16, - "column": 1 - }, - { - "type": "COMMENT", - "lexeme": "// Define operations on our custom type", - "line": 17, - "column": 1 - }, - { - "type": "NEWLINE", - "lexeme": "\n", - "line": 17, - "column": 40 - }, { "type": "EXTEND", "lexeme": "extend", - "line": 18, + "line": 14, "column": 1 }, { "type": "WHITESPACE", "lexeme": " ", - "line": 18, + "line": 14, "column": 7 }, { "type": "IDENTIFIER", "lexeme": "GeoLocation", - "line": 18, + "line": 14, "column": 8 }, { "type": "WHITESPACE", "lexeme": " ", - "line": 18, + "line": 14, "column": 19 }, { "type": "LEFT_BRACE", "lexeme": "{", - "line": 18, + "line": 14, "column": 20 }, { "type": "NEWLINE", "lexeme": "\n", - "line": 18, + "line": 14, "column": 21 }, { "type": "WHITESPACE", "lexeme": " ", - "line": 19, - "column": 1 - }, - { - "type": "COMMENT", - "lexeme": "// This type is compatible with the `-` operation with another GeoLocation", - "line": 19, - "column": 5 - }, - { - "type": "NEWLINE", - "lexeme": "\n", - "line": 19, - "column": 79 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 20, - "column": 1 - }, - { - "type": "COMMENT", - "lexeme": "// i.e. you can subtract a GeoLocation from another GeoLocation, resulting", - "line": 20, - "column": 5 - }, - { - "type": "NEWLINE", - "lexeme": "\n", - "line": 20, - "column": 79 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 21, - "column": 1 - }, - { - "type": "COMMENT", - "lexeme": "// in a Difference of GeoLocations", - "line": 21, - "column": 5 - }, - { - "type": "NEWLINE", - "lexeme": "\n", - "line": 21, - "column": 39 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 22, - "column": 1 - }, - { - "type": "DEF", - "lexeme": "def", - "line": 22, - "column": 5 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 22, - "column": 8 - }, - { - "type": "IDENTIFIER", - "lexeme": "__sub__", - "line": 22, - "column": 9 - }, - { - "type": "COLON", - "lexeme": ":", - "line": 22, - "column": 16 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 22, - "column": 17 - }, - { - "type": "FUNC", - "lexeme": "fn", - "line": 22, - "column": 18 - }, - { - "type": "LEFT_PAREN", - "lexeme": "(", - "line": 22, - "column": 20 - }, - { - "type": "IDENTIFIER", - "lexeme": "GeoLocation", - "line": 22, - "column": 21 - }, - { - "type": "COMMA", - "lexeme": ",", - "line": 22, - "column": 32 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 22, - "column": 33 - }, - { - "type": "SLASH", - "lexeme": "/", - "line": 22, - "column": 34 - }, - { - "type": "RIGHT_PAREN", - "lexeme": ")", - "line": 22, - "column": 35 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 22, - "column": 36 - }, - { - "type": "ARROW", - "lexeme": "->", - "line": 22, - "column": 37 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 22, - "column": 39 - }, - { - "type": "IDENTIFIER", - "lexeme": "Difference", - "line": 22, - "column": 40 - }, - { - "type": "LEFT_BRACKET", - "lexeme": "[", - "line": 22, - "column": 50 - }, - { - "type": "IDENTIFIER", - "lexeme": "GeoLocation", - "line": 22, - "column": 51 - }, - { - "type": "RIGHT_BRACKET", - "lexeme": "]", - "line": 22, - "column": 62 - }, - { - "type": "NEWLINE", - "lexeme": "\n", - "line": 22, - "column": 63 - }, - { - "type": "RIGHT_BRACE", - "lexeme": "}", - "line": 23, - "column": 1 - }, - { - "type": "NEWLINE", - "lexeme": "\n", - "line": 23, - "column": 2 - }, - { - "type": "NEWLINE", - "lexeme": "\n", - "line": 24, - "column": 1 - }, - { - "type": "COMMENT", - "lexeme": "// For complex generics, you need to specify how the genericity the properties", - "line": 25, - "column": 1 - }, - { - "type": "NEWLINE", - "lexeme": "\n", - "line": 25, - "column": 79 - }, - { - "type": "COMMENT", - "lexeme": "// are handled", - "line": 26, - "column": 1 - }, - { - "type": "NEWLINE", - "lexeme": "\n", - "line": 26, - "column": 15 - }, - { - "type": "TYPE", - "lexeme": "type", - "line": 27, - "column": 1 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 27, - "column": 5 - }, - { - "type": "IDENTIFIER", - "lexeme": "Difference", - "line": 27, - "column": 6 - }, - { - "type": "LEFT_BRACKET", - "lexeme": "[", - "line": 27, - "column": 16 - }, - { - "type": "IDENTIFIER", - "lexeme": "GeoLocation", - "line": 27, - "column": 17 - }, - { - "type": "RIGHT_BRACKET", - "lexeme": "]", - "line": 27, - "column": 28 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 27, - "column": 29 - }, - { - "type": "EQUAL", - "lexeme": "=", - "line": 27, - "column": 30 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 27, - "column": 31 - }, - { - "type": "LEFT_BRACE", - "lexeme": "{", - "line": 27, - "column": 32 - }, - { - "type": "NEWLINE", - "lexeme": "\n", - "line": 27, - "column": 33 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 28, + "line": 15, "column": 1 }, { "type": "PROP", "lexeme": "prop", - "line": 28, + "line": 15, "column": 5 }, { "type": "WHITESPACE", "lexeme": " ", - "line": 28, + "line": 15, "column": 9 }, { "type": "IDENTIFIER", "lexeme": "lat", - "line": 28, + "line": 15, "column": 10 }, { "type": "COLON", "lexeme": ":", - "line": 28, + "line": 15, "column": 13 }, { "type": "WHITESPACE", "lexeme": " ", - "line": 28, + "line": 15, "column": 14 }, - { - "type": "IDENTIFIER", - "lexeme": "Difference", - "line": 28, - "column": 15 - }, - { - "type": "LEFT_BRACKET", - "lexeme": "[", - "line": 28, - "column": 25 - }, { "type": "IDENTIFIER", "lexeme": "Latitude", - "line": 28, - "column": 26 - }, - { - "type": "RIGHT_BRACKET", - "lexeme": "]", - "line": 28, - "column": 34 + "line": 15, + "column": 15 }, { "type": "NEWLINE", "lexeme": "\n", - "line": 28, - "column": 35 + "line": 15, + "column": 23 }, { "type": "WHITESPACE", "lexeme": " ", - "line": 29, + "line": 16, "column": 1 }, { "type": "PROP", "lexeme": "prop", - "line": 29, + "line": 16, "column": 5 }, { "type": "WHITESPACE", "lexeme": " ", - "line": 29, + "line": 16, "column": 9 }, { "type": "IDENTIFIER", "lexeme": "lon", - "line": 29, + "line": 16, "column": 10 }, { "type": "COLON", "lexeme": ":", - "line": 29, + "line": 16, "column": 13 }, { "type": "WHITESPACE", "lexeme": " ", - "line": 29, + "line": 16, "column": 14 }, - { - "type": "IDENTIFIER", - "lexeme": "Difference", - "line": 29, - "column": 15 - }, - { - "type": "LEFT_BRACKET", - "lexeme": "[", - "line": 29, - "column": 25 - }, { "type": "IDENTIFIER", "lexeme": "Longitude", - "line": 29, - "column": 26 - }, - { - "type": "RIGHT_BRACKET", - "lexeme": "]", - "line": 29, - "column": 35 + "line": 16, + "column": 15 }, { "type": "NEWLINE", "lexeme": "\n", - "line": 29, - "column": 36 + "line": 16, + "column": 24 }, { "type": "RIGHT_BRACE", "lexeme": "}", - "line": 30, + "line": 17, "column": 1 }, { "type": "NEWLINE", "lexeme": "\n", - "line": 30, + "line": 17, "column": 2 }, { "type": "NEWLINE", "lexeme": "\n", - "line": 31, + "line": 18, "column": 1 }, { - "type": "COMMENT", - "lexeme": "// Simple operation defined on our custom types", - "line": 32, + "type": "TYPE", + "lexeme": "type", + "line": 19, + "column": 1 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 19, + "column": 5 + }, + { + "type": "IDENTIFIER", + "lexeme": "GeoLocationDifference", + "line": 19, + "column": 6 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 19, + "column": 27 + }, + { + "type": "EQUAL", + "lexeme": "=", + "line": 19, + "column": 28 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 19, + "column": 29 + }, + { + "type": "IDENTIFIER", + "lexeme": "object", + "line": 19, + "column": 30 + }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 19, + "column": 36 + }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 20, + "column": 1 + }, + { + "type": "EXTEND", + "lexeme": "extend", + "line": 21, + "column": 1 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 21, + "column": 7 + }, + { + "type": "IDENTIFIER", + "lexeme": "GeoLocationDifference", + "line": 21, + "column": 8 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 21, + "column": 29 + }, + { + "type": "LEFT_BRACE", + "lexeme": "{", + "line": 21, + "column": 30 + }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 21, + "column": 31 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 22, + "column": 1 + }, + { + "type": "PROP", + "lexeme": "prop", + "line": 22, + "column": 5 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 22, + "column": 9 + }, + { + "type": "IDENTIFIER", + "lexeme": "lat", + "line": 22, + "column": 10 + }, + { + "type": "COLON", + "lexeme": ":", + "line": 22, + "column": 13 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 22, + "column": 14 + }, + { + "type": "IDENTIFIER", + "lexeme": "Difference", + "line": 22, + "column": 15 + }, + { + "type": "LEFT_BRACKET", + "lexeme": "[", + "line": 22, + "column": 25 + }, + { + "type": "IDENTIFIER", + "lexeme": "Latitude", + "line": 22, + "column": 26 + }, + { + "type": "RIGHT_BRACKET", + "lexeme": "]", + "line": 22, + "column": 34 + }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 22, + "column": 35 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 23, + "column": 1 + }, + { + "type": "PROP", + "lexeme": "prop", + "line": 23, + "column": 5 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 23, + "column": 9 + }, + { + "type": "IDENTIFIER", + "lexeme": "lon", + "line": 23, + "column": 10 + }, + { + "type": "COLON", + "lexeme": ":", + "line": 23, + "column": 13 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 23, + "column": 14 + }, + { + "type": "IDENTIFIER", + "lexeme": "Difference", + "line": 23, + "column": 15 + }, + { + "type": "LEFT_BRACKET", + "lexeme": "[", + "line": 23, + "column": 25 + }, + { + "type": "IDENTIFIER", + "lexeme": "Longitude", + "line": 23, + "column": 26 + }, + { + "type": "RIGHT_BRACKET", + "lexeme": "]", + "line": 23, + "column": 35 + }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 23, + "column": 36 + }, + { + "type": "RIGHT_BRACE", + "lexeme": "}", + "line": 24, "column": 1 }, { "type": "NEWLINE", "lexeme": "\n", - "line": 32, + "line": 24, + "column": 2 + }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 25, + "column": 1 + }, + { + "type": "COMMENT", + "lexeme": "// Define operations on our custom type", + "line": 26, + "column": 1 + }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 26, + "column": 40 + }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 27, + "column": 1 + }, + { + "type": "COMMENT", + "lexeme": "// Simple operation defined on our custom types", + "line": 28, + "column": 1 + }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 28, "column": 48 }, + { + "type": "EXTEND", + "lexeme": "extend", + "line": 29, + "column": 1 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 29, + "column": 7 + }, + { + "type": "IDENTIFIER", + "lexeme": "Latitude", + "line": 29, + "column": 8 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 29, + "column": 16 + }, + { + "type": "LEFT_BRACE", + "lexeme": "{", + "line": 29, + "column": 17 + }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 29, + "column": 18 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 30, + "column": 1 + }, + { + "type": "DEF", + "lexeme": "def", + "line": 30, + "column": 5 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 30, + "column": 8 + }, + { + "type": "IDENTIFIER", + "lexeme": "__sub__", + "line": 30, + "column": 9 + }, + { + "type": "COLON", + "lexeme": ":", + "line": 30, + "column": 16 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 30, + "column": 17 + }, + { + "type": "FUNC", + "lexeme": "fn", + "line": 30, + "column": 18 + }, + { + "type": "LEFT_PAREN", + "lexeme": "(", + "line": 30, + "column": 20 + }, + { + "type": "IDENTIFIER", + "lexeme": "Latitude", + "line": 30, + "column": 21 + }, + { + "type": "COMMA", + "lexeme": ",", + "line": 30, + "column": 29 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 30, + "column": 30 + }, + { + "type": "SLASH", + "lexeme": "/", + "line": 30, + "column": 31 + }, + { + "type": "RIGHT_PAREN", + "lexeme": ")", + "line": 30, + "column": 32 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 30, + "column": 33 + }, + { + "type": "ARROW", + "lexeme": "->", + "line": 30, + "column": 34 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 30, + "column": 36 + }, + { + "type": "IDENTIFIER", + "lexeme": "Difference", + "line": 30, + "column": 37 + }, + { + "type": "LEFT_BRACKET", + "lexeme": "[", + "line": 30, + "column": 47 + }, + { + "type": "IDENTIFIER", + "lexeme": "Latitude", + "line": 30, + "column": 48 + }, + { + "type": "RIGHT_BRACKET", + "lexeme": "]", + "line": 30, + "column": 56 + }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 30, + "column": 57 + }, + { + "type": "RIGHT_BRACE", + "lexeme": "}", + "line": 31, + "column": 1 + }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 31, + "column": 2 + }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 32, + "column": 1 + }, { "type": "EXTEND", "lexeme": "extend", @@ -1130,7 +1124,7 @@ }, { "type": "IDENTIFIER", - "lexeme": "Latitude", + "lexeme": "Longitude", "line": 33, "column": 8 }, @@ -1138,19 +1132,19 @@ "type": "WHITESPACE", "lexeme": " ", "line": 33, - "column": 16 + "column": 17 }, { "type": "LEFT_BRACE", "lexeme": "{", "line": 33, - "column": 17 + "column": 18 }, { "type": "NEWLINE", "lexeme": "\n", "line": 33, - "column": 18 + "column": 19 }, { "type": "WHITESPACE", @@ -1202,7 +1196,7 @@ }, { "type": "IDENTIFIER", - "lexeme": "Latitude", + "lexeme": "Longitude", "line": 34, "column": 21 }, @@ -1210,73 +1204,73 @@ "type": "COMMA", "lexeme": ",", "line": 34, - "column": 29 + "column": 30 }, { "type": "WHITESPACE", "lexeme": " ", "line": 34, - "column": 30 + "column": 31 }, { "type": "SLASH", "lexeme": "/", "line": 34, - "column": 31 + "column": 32 }, { "type": "RIGHT_PAREN", "lexeme": ")", "line": 34, - "column": 32 + "column": 33 }, { "type": "WHITESPACE", "lexeme": " ", "line": 34, - "column": 33 + "column": 34 }, { "type": "ARROW", "lexeme": "->", "line": 34, - "column": 34 + "column": 35 }, { "type": "WHITESPACE", "lexeme": " ", "line": 34, - "column": 36 + "column": 37 }, { "type": "IDENTIFIER", "lexeme": "Difference", "line": 34, - "column": 37 + "column": 38 }, { "type": "LEFT_BRACKET", "lexeme": "[", "line": 34, - "column": 47 + "column": 48 }, { "type": "IDENTIFIER", - "lexeme": "Latitude", + "lexeme": "Longitude", "line": 34, - "column": 48 + "column": 49 }, { "type": "RIGHT_BRACKET", "lexeme": "]", "line": 34, - "column": 56 + "column": 58 }, { "type": "NEWLINE", "lexeme": "\n", "line": 34, - "column": 57 + "column": 59 }, { "type": "RIGHT_BRACE", @@ -1310,7 +1304,7 @@ }, { "type": "IDENTIFIER", - "lexeme": "Longitude", + "lexeme": "GeoLocation", "line": 37, "column": 8 }, @@ -1318,19 +1312,19 @@ "type": "WHITESPACE", "lexeme": " ", "line": 37, - "column": 17 + "column": 19 }, { "type": "LEFT_BRACE", "lexeme": "{", "line": 37, - "column": 18 + "column": 20 }, { "type": "NEWLINE", "lexeme": "\n", "line": 37, - "column": 19 + "column": 21 }, { "type": "WHITESPACE", @@ -1339,674 +1333,308 @@ "column": 1 }, { - "type": "DEF", - "lexeme": "def", + "type": "COMMENT", + "lexeme": "// This type is compatible with the `-` operation with another GeoLocation", "line": 38, "column": 5 }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 38, - "column": 8 - }, - { - "type": "IDENTIFIER", - "lexeme": "__sub__", - "line": 38, - "column": 9 - }, - { - "type": "COLON", - "lexeme": ":", - "line": 38, - "column": 16 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 38, - "column": 17 - }, - { - "type": "FUNC", - "lexeme": "fn", - "line": 38, - "column": 18 - }, - { - "type": "LEFT_PAREN", - "lexeme": "(", - "line": 38, - "column": 20 - }, - { - "type": "IDENTIFIER", - "lexeme": "Longitude", - "line": 38, - "column": 21 - }, - { - "type": "COMMA", - "lexeme": ",", - "line": 38, - "column": 30 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 38, - "column": 31 - }, - { - "type": "SLASH", - "lexeme": "/", - "line": 38, - "column": 32 - }, - { - "type": "RIGHT_PAREN", - "lexeme": ")", - "line": 38, - "column": 33 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 38, - "column": 34 - }, - { - "type": "ARROW", - "lexeme": "->", - "line": 38, - "column": 35 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 38, - "column": 37 - }, - { - "type": "IDENTIFIER", - "lexeme": "Difference", - "line": 38, - "column": 38 - }, - { - "type": "LEFT_BRACKET", - "lexeme": "[", - "line": 38, - "column": 48 - }, - { - "type": "IDENTIFIER", - "lexeme": "Longitude", - "line": 38, - "column": 49 - }, - { - "type": "RIGHT_BRACKET", - "lexeme": "]", - "line": 38, - "column": 58 - }, { "type": "NEWLINE", "lexeme": "\n", "line": 38, - "column": 59 + "column": 79 }, { - "type": "RIGHT_BRACE", - "lexeme": "}", + "type": "WHITESPACE", + "lexeme": " ", "line": 39, "column": 1 }, { - "type": "NEWLINE", - "lexeme": "\n", + "type": "COMMENT", + "lexeme": "// i.e. you can subtract a GeoLocation from another GeoLocation, resulting", "line": 39, - "column": 2 + "column": 5 }, { "type": "NEWLINE", "lexeme": "\n", + "line": 39, + "column": 79 + }, + { + "type": "WHITESPACE", + "lexeme": " ", "line": 40, "column": 1 }, { "type": "COMMENT", - "lexeme": "// Predefined custom predicates that can be referenced in other definitions", - "line": 41, - "column": 1 + "lexeme": "// in a GeoLocationDifference", + "line": 40, + "column": 5 }, { "type": "NEWLINE", "lexeme": "\n", - "line": 41, - "column": 76 + "line": 40, + "column": 34 }, { - "type": "PREDICATE", - "lexeme": "predicate", - "line": 42, + "type": "WHITESPACE", + "lexeme": " ", + "line": 41, "column": 1 }, + { + "type": "DEF", + "lexeme": "def", + "line": 41, + "column": 5 + }, { "type": "WHITESPACE", "lexeme": " ", - "line": 42, - "column": 10 + "line": 41, + "column": 8 }, { "type": "IDENTIFIER", - "lexeme": "Positive", - "line": 42, - "column": 11 - }, - { - "type": "LEFT_PAREN", - "lexeme": "(", - "line": 42, - "column": 19 - }, - { - "type": "IDENTIFIER", - "lexeme": "v", - "line": 42, - "column": 20 + "lexeme": "__sub__", + "line": 41, + "column": 9 }, { "type": "COLON", "lexeme": ":", - "line": 42, + "line": 41, + "column": 16 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 41, + "column": 17 + }, + { + "type": "FUNC", + "lexeme": "fn", + "line": 41, + "column": 18 + }, + { + "type": "LEFT_PAREN", + "lexeme": "(", + "line": 41, + "column": 20 + }, + { + "type": "IDENTIFIER", + "lexeme": "GeoLocation", + "line": 41, "column": 21 }, { - "type": "WHITESPACE", - "lexeme": " ", - "line": 42, - "column": 22 - }, - { - "type": "IDENTIFIER", - "lexeme": "float", - "line": 42, - "column": 23 - }, - { - "type": "RIGHT_PAREN", - "lexeme": ")", - "line": 42, - "column": 28 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 42, - "column": 29 - }, - { - "type": "EQUAL", - "lexeme": "=", - "line": 42, - "column": 30 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 42, - "column": 31 - }, - { - "type": "IDENTIFIER", - "lexeme": "v", - "line": 42, + "type": "COMMA", + "lexeme": ",", + "line": 41, "column": 32 }, { "type": "WHITESPACE", "lexeme": " ", - "line": 42, + "line": 41, "column": 33 }, { - "type": "GREATER_EQUAL", - "lexeme": ">=", - "line": 42, + "type": "SLASH", + "lexeme": "/", + "line": 41, "column": 34 }, + { + "type": "RIGHT_PAREN", + "lexeme": ")", + "line": 41, + "column": 35 + }, { "type": "WHITESPACE", "lexeme": " ", - "line": 42, + "line": 41, "column": 36 }, { - "type": "NUMBER", - "lexeme": "0", - "line": 42, + "type": "ARROW", + "lexeme": "->", + "line": 41, "column": 37 }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 41, + "column": 39 + }, + { + "type": "IDENTIFIER", + "lexeme": "GeoLocationDifference", + "line": 41, + "column": 40 + }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 41, + "column": 61 + }, + { + "type": "RIGHT_BRACE", + "lexeme": "}", + "line": 42, + "column": 1 + }, { "type": "NEWLINE", "lexeme": "\n", "line": 42, - "column": 38 + "column": 2 + }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 43, + "column": 1 + }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 44, + "column": 1 + }, + { + "type": "COMMENT", + "lexeme": "// Predefined custom predicates that can be referenced in other definitions", + "line": 45, + "column": 1 + }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 45, + "column": 76 }, { "type": "PREDICATE", "lexeme": "predicate", - "line": 43, + "line": 46, "column": 1 }, { "type": "WHITESPACE", "lexeme": " ", - "line": 43, + "line": 46, "column": 10 }, { "type": "IDENTIFIER", - "lexeme": "StrictlyPositive", - "line": 43, + "lexeme": "Positive", + "line": 46, "column": 11 }, { "type": "LEFT_PAREN", "lexeme": "(", - "line": 43, - "column": 27 + "line": 46, + "column": 19 }, { "type": "IDENTIFIER", "lexeme": "v", - "line": 43, - "column": 28 + "line": 46, + "column": 20 }, { "type": "COLON", "lexeme": ":", - "line": 43, - "column": 29 + "line": 46, + "column": 21 }, { "type": "WHITESPACE", "lexeme": " ", - "line": 43, - "column": 30 + "line": 46, + "column": 22 }, { "type": "IDENTIFIER", "lexeme": "float", - "line": 43, - "column": 31 - }, - { - "type": "RIGHT_PAREN", - "lexeme": ")", - "line": 43, - "column": 36 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 43, - "column": 37 - }, - { - "type": "EQUAL", - "lexeme": "=", - "line": 43, - "column": 38 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 43, - "column": 39 - }, - { - "type": "IDENTIFIER", - "lexeme": "v", - "line": 43, - "column": 40 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 43, - "column": 41 - }, - { - "type": "GREATER", - "lexeme": ">", - "line": 43, - "column": 42 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 43, - "column": 43 - }, - { - "type": "NUMBER", - "lexeme": "0", - "line": 43, - "column": 44 - }, - { - "type": "NEWLINE", - "lexeme": "\n", - "line": 43, - "column": 45 - }, - { - "type": "PREDICATE", - "lexeme": "predicate", - "line": 44, - "column": 1 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 44, - "column": 10 - }, - { - "type": "IDENTIFIER", - "lexeme": "Equatorial", - "line": 44, - "column": 11 - }, - { - "type": "LEFT_PAREN", - "lexeme": "(", - "line": 44, - "column": 21 - }, - { - "type": "IDENTIFIER", - "lexeme": "loc", - "line": 44, - "column": 22 - }, - { - "type": "COLON", - "lexeme": ":", - "line": 44, - "column": 25 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 44, - "column": 26 - }, - { - "type": "IDENTIFIER", - "lexeme": "GeoLocation", - "line": 44, - "column": 27 - }, - { - "type": "RIGHT_PAREN", - "lexeme": ")", - "line": 44, - "column": 38 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 44, - "column": 39 - }, - { - "type": "EQUAL", - "lexeme": "=", - "line": 44, - "column": 40 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 44, - "column": 41 - }, - { - "type": "LEFT_PAREN", - "lexeme": "(", - "line": 44, - "column": 42 - }, - { - "type": "MINUS", - "lexeme": "-", - "line": 44, - "column": 43 - }, - { - "type": "NUMBER", - "lexeme": "10", - "line": 44, - "column": 44 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 44, - "column": 46 - }, - { - "type": "LESS_EQUAL", - "lexeme": "<=", - "line": 44, - "column": 47 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 44, - "column": 49 - }, - { - "type": "IDENTIFIER", - "lexeme": "loc", - "line": 44, - "column": 50 - }, - { - "type": "DOT", - "lexeme": ".", - "line": 44, - "column": 53 - }, - { - "type": "IDENTIFIER", - "lexeme": "lat", - "line": 44, - "column": 54 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 44, - "column": 57 - }, - { - "type": "LESS_EQUAL", - "lexeme": "<=", - "line": 44, - "column": 58 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 44, - "column": 60 - }, - { - "type": "NUMBER", - "lexeme": "10", - "line": 44, - "column": 61 - }, - { - "type": "RIGHT_PAREN", - "lexeme": ")", - "line": 44, - "column": 63 - }, - { - "type": "NEWLINE", - "lexeme": "\n", - "line": 44, - "column": 64 - }, - { - "type": "PREDICATE", - "lexeme": "predicate", - "line": 45, - "column": 1 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 45, - "column": 10 - }, - { - "type": "IDENTIFIER", - "lexeme": "Arctic", - "line": 45, - "column": 11 - }, - { - "type": "LEFT_PAREN", - "lexeme": "(", - "line": 45, - "column": 17 - }, - { - "type": "IDENTIFIER", - "lexeme": "loc", - "line": 45, - "column": 18 - }, - { - "type": "COLON", - "lexeme": ":", - "line": 45, - "column": 21 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 45, - "column": 22 - }, - { - "type": "IDENTIFIER", - "lexeme": "GeoLocation", - "line": 45, + "line": 46, "column": 23 }, { "type": "RIGHT_PAREN", "lexeme": ")", - "line": 45, + "line": 46, + "column": 28 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 46, + "column": 29 + }, + { + "type": "EQUAL", + "lexeme": "=", + "line": 46, + "column": 30 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 46, + "column": 31 + }, + { + "type": "IDENTIFIER", + "lexeme": "v", + "line": 46, + "column": 32 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 46, + "column": 33 + }, + { + "type": "GREATER_EQUAL", + "lexeme": ">=", + "line": 46, "column": 34 }, { "type": "WHITESPACE", "lexeme": " ", - "line": 45, - "column": 35 - }, - { - "type": "EQUAL", - "lexeme": "=", - "line": 45, + "line": 46, "column": 36 }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 45, - "column": 37 - }, - { - "type": "LEFT_PAREN", - "lexeme": "(", - "line": 45, - "column": 38 - }, - { - "type": "IDENTIFIER", - "lexeme": "loc", - "line": 45, - "column": 39 - }, - { - "type": "DOT", - "lexeme": ".", - "line": 45, - "column": 42 - }, - { - "type": "IDENTIFIER", - "lexeme": "lat", - "line": 45, - "column": 43 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 45, - "column": 46 - }, - { - "type": "GREATER_EQUAL", - "lexeme": ">=", - "line": 45, - "column": 47 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 45, - "column": 49 - }, { "type": "NUMBER", - "lexeme": "66", - "line": 45, - "column": 50 - }, - { - "type": "RIGHT_PAREN", - "lexeme": ")", - "line": 45, - "column": 52 - }, - { - "type": "NEWLINE", - "lexeme": "\n", - "line": 45, - "column": 53 + "lexeme": "0", + "line": 46, + "column": 37 }, { "type": "NEWLINE", "lexeme": "\n", "line": 46, - "column": 1 + "column": 38 }, { - "type": "TYPE", - "lexeme": "type", + "type": "PREDICATE", + "lexeme": "predicate", "line": 47, "column": 1 }, @@ -2014,265 +1642,451 @@ "type": "WHITESPACE", "lexeme": " ", "line": 47, - "column": 5 + "column": 10 }, { "type": "IDENTIFIER", - "lexeme": "Person", + "lexeme": "StrictlyPositive", "line": 47, - "column": 6 + "column": 11 + }, + { + "type": "LEFT_PAREN", + "lexeme": "(", + "line": 47, + "column": 27 + }, + { + "type": "IDENTIFIER", + "lexeme": "v", + "line": 47, + "column": 28 + }, + { + "type": "COLON", + "lexeme": ":", + "line": 47, + "column": 29 }, { "type": "WHITESPACE", "lexeme": " ", "line": 47, - "column": 12 + "column": 30 + }, + { + "type": "IDENTIFIER", + "lexeme": "float", + "line": 47, + "column": 31 + }, + { + "type": "RIGHT_PAREN", + "lexeme": ")", + "line": 47, + "column": 36 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 47, + "column": 37 }, { "type": "EQUAL", "lexeme": "=", "line": 47, - "column": 13 + "column": 38 }, { "type": "WHITESPACE", "lexeme": " ", "line": 47, - "column": 14 - }, - { - "type": "LEFT_BRACE", - "lexeme": "{", - "line": 47, - "column": 15 - }, - { - "type": "NEWLINE", - "lexeme": "\n", - "line": 47, - "column": 16 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 48, - "column": 1 - }, - { - "type": "PROP", - "lexeme": "prop", - "line": 48, - "column": 5 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 48, - "column": 9 - }, - { - "type": "IDENTIFIER", - "lexeme": "name", - "line": 48, - "column": 10 - }, - { - "type": "COLON", - "lexeme": ":", - "line": 48, - "column": 14 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 48, - "column": 15 - }, - { - "type": "IDENTIFIER", - "lexeme": "str", - "line": 48, - "column": 16 - }, - { - "type": "NEWLINE", - "lexeme": "\n", - "line": 48, - "column": 19 - }, - { - "type": "NEWLINE", - "lexeme": "\n", - "line": 49, - "column": 1 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 50, - "column": 1 - }, - { - "type": "COMMENT", - "lexeme": "// Property with an inline constraint", - "line": 50, - "column": 5 - }, - { - "type": "NEWLINE", - "lexeme": "\n", - "line": 50, - "column": 42 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 51, - "column": 1 - }, - { - "type": "PROP", - "lexeme": "prop", - "line": 51, - "column": 5 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 51, - "column": 9 - }, - { - "type": "IDENTIFIER", - "lexeme": "age", - "line": 51, - "column": 10 - }, - { - "type": "COLON", - "lexeme": ":", - "line": 51, - "column": 13 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 51, - "column": 14 - }, - { - "type": "IDENTIFIER", - "lexeme": "Optional", - "line": 51, - "column": 15 - }, - { - "type": "LEFT_BRACKET", - "lexeme": "[", - "line": 51, - "column": 23 - }, - { - "type": "IDENTIFIER", - "lexeme": "int", - "line": 51, - "column": 24 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 51, - "column": 27 - }, - { - "type": "WHERE", - "lexeme": "where", - "line": 51, - "column": 28 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 51, - "column": 33 - }, - { - "type": "LEFT_PAREN", - "lexeme": "(", - "line": 51, - "column": 34 - }, - { - "type": "NUMBER", - "lexeme": "0", - "line": 51, - "column": 35 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 51, - "column": 36 - }, - { - "type": "LESS_EQUAL", - "lexeme": "<=", - "line": 51, - "column": 37 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 51, "column": 39 }, { - "type": "UNDERSCORE", - "lexeme": "_", - "line": 51, + "type": "IDENTIFIER", + "lexeme": "v", + "line": 47, "column": 40 }, { "type": "WHITESPACE", "lexeme": " ", - "line": 51, + "line": 47, "column": 41 }, { - "type": "LESS", - "lexeme": "<", - "line": 51, + "type": "GREATER", + "lexeme": ">", + "line": 47, "column": 42 }, { "type": "WHITESPACE", "lexeme": " ", - "line": 51, + "line": 47, "column": 43 }, { "type": "NUMBER", - "lexeme": "150", - "line": 51, + "lexeme": "0", + "line": 47, "column": 44 }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 47, + "column": 45 + }, + { + "type": "PREDICATE", + "lexeme": "predicate", + "line": 48, + "column": 1 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 48, + "column": 10 + }, + { + "type": "IDENTIFIER", + "lexeme": "Equatorial", + "line": 48, + "column": 11 + }, + { + "type": "LEFT_PAREN", + "lexeme": "(", + "line": 48, + "column": 21 + }, + { + "type": "IDENTIFIER", + "lexeme": "loc", + "line": 48, + "column": 22 + }, + { + "type": "COLON", + "lexeme": ":", + "line": 48, + "column": 25 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 48, + "column": 26 + }, + { + "type": "IDENTIFIER", + "lexeme": "GeoLocation", + "line": 48, + "column": 27 + }, { "type": "RIGHT_PAREN", "lexeme": ")", - "line": 51, + "line": 48, + "column": 38 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 48, + "column": 39 + }, + { + "type": "EQUAL", + "lexeme": "=", + "line": 48, + "column": 40 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 48, + "column": 41 + }, + { + "type": "LEFT_PAREN", + "lexeme": "(", + "line": 48, + "column": 42 + }, + { + "type": "MINUS", + "lexeme": "-", + "line": 48, + "column": 43 + }, + { + "type": "NUMBER", + "lexeme": "10", + "line": 48, + "column": 44 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 48, + "column": 46 + }, + { + "type": "LESS_EQUAL", + "lexeme": "<=", + "line": 48, "column": 47 }, { - "type": "RIGHT_BRACKET", - "lexeme": "]", + "type": "WHITESPACE", + "lexeme": " ", + "line": 48, + "column": 49 + }, + { + "type": "IDENTIFIER", + "lexeme": "loc", + "line": 48, + "column": 50 + }, + { + "type": "DOT", + "lexeme": ".", + "line": 48, + "column": 53 + }, + { + "type": "IDENTIFIER", + "lexeme": "lat", + "line": 48, + "column": 54 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 48, + "column": 57 + }, + { + "type": "LESS_EQUAL", + "lexeme": "<=", + "line": 48, + "column": 58 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 48, + "column": 60 + }, + { + "type": "NUMBER", + "lexeme": "10", + "line": 48, + "column": 61 + }, + { + "type": "RIGHT_PAREN", + "lexeme": ")", + "line": 48, + "column": 63 + }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 48, + "column": 64 + }, + { + "type": "PREDICATE", + "lexeme": "predicate", + "line": 49, + "column": 1 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 49, + "column": 10 + }, + { + "type": "IDENTIFIER", + "lexeme": "Arctic", + "line": 49, + "column": 11 + }, + { + "type": "LEFT_PAREN", + "lexeme": "(", + "line": 49, + "column": 17 + }, + { + "type": "IDENTIFIER", + "lexeme": "loc", + "line": 49, + "column": 18 + }, + { + "type": "COLON", + "lexeme": ":", + "line": 49, + "column": 21 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 49, + "column": 22 + }, + { + "type": "IDENTIFIER", + "lexeme": "GeoLocation", + "line": 49, + "column": 23 + }, + { + "type": "RIGHT_PAREN", + "lexeme": ")", + "line": 49, + "column": 34 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 49, + "column": 35 + }, + { + "type": "EQUAL", + "lexeme": "=", + "line": 49, + "column": 36 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 49, + "column": 37 + }, + { + "type": "LEFT_PAREN", + "lexeme": "(", + "line": 49, + "column": 38 + }, + { + "type": "IDENTIFIER", + "lexeme": "loc", + "line": 49, + "column": 39 + }, + { + "type": "DOT", + "lexeme": ".", + "line": 49, + "column": 42 + }, + { + "type": "IDENTIFIER", + "lexeme": "lat", + "line": 49, + "column": 43 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 49, + "column": 46 + }, + { + "type": "GREATER_EQUAL", + "lexeme": ">=", + "line": 49, + "column": 47 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 49, + "column": 49 + }, + { + "type": "NUMBER", + "lexeme": "66", + "line": 49, + "column": 50 + }, + { + "type": "RIGHT_PAREN", + "lexeme": ")", + "line": 49, + "column": 52 + }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 49, + "column": 53 + }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 50, + "column": 1 + }, + { + "type": "TYPE", + "lexeme": "type", "line": 51, - "column": 48 + "column": 1 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 51, + "column": 5 + }, + { + "type": "IDENTIFIER", + "lexeme": "Person", + "line": 51, + "column": 6 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 51, + "column": 12 + }, + { + "type": "EQUAL", + "lexeme": "=", + "line": 51, + "column": 13 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 51, + "column": 14 + }, + { + "type": "IDENTIFIER", + "lexeme": "object", + "line": 51, + "column": 15 }, { "type": "NEWLINE", "lexeme": "\n", "line": 51, - "column": 49 + "column": 21 }, { "type": "NEWLINE", @@ -2281,22 +2095,40 @@ "column": 1 }, { - "type": "WHITESPACE", - "lexeme": " ", + "type": "EXTEND", + "lexeme": "extend", "line": 53, "column": 1 }, { - "type": "COMMENT", - "lexeme": "// Property referencing a predicate", + "type": "WHITESPACE", + "lexeme": " ", "line": 53, - "column": 5 + "column": 7 + }, + { + "type": "IDENTIFIER", + "lexeme": "Person", + "line": 53, + "column": 8 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 53, + "column": 14 + }, + { + "type": "LEFT_BRACE", + "lexeme": "{", + "line": 53, + "column": 15 }, { "type": "NEWLINE", "lexeme": "\n", "line": 53, - "column": 40 + "column": 16 }, { "type": "WHITESPACE", @@ -2318,7 +2150,7 @@ }, { "type": "IDENTIFIER", - "lexeme": "height", + "lexeme": "name", "line": 54, "column": 10 }, @@ -2326,49 +2158,25 @@ "type": "COLON", "lexeme": ":", "line": 54, + "column": 14 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 54, + "column": 15 + }, + { + "type": "IDENTIFIER", + "lexeme": "str", + "line": 54, "column": 16 }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 54, - "column": 17 - }, - { - "type": "IDENTIFIER", - "lexeme": "float", - "line": 54, - "column": 18 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 54, - "column": 23 - }, - { - "type": "WHERE", - "lexeme": "where", - "line": 54, - "column": 24 - }, - { - "type": "WHITESPACE", - "lexeme": " ", - "line": 54, - "column": 29 - }, - { - "type": "IDENTIFIER", - "lexeme": "StrictlyPositive", - "line": 54, - "column": 30 - }, { "type": "NEWLINE", "lexeme": "\n", "line": 54, - "column": 46 + "column": 19 }, { "type": "NEWLINE", @@ -2382,64 +2190,334 @@ "line": 56, "column": 1 }, + { + "type": "COMMENT", + "lexeme": "// Property with an inline constraint", + "line": 56, + "column": 5 + }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 56, + "column": 42 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 57, + "column": 1 + }, { "type": "PROP", "lexeme": "prop", - "line": 56, + "line": 57, "column": 5 }, { "type": "WHITESPACE", "lexeme": " ", - "line": 56, + "line": 57, "column": 9 }, { "type": "IDENTIFIER", - "lexeme": "home", - "line": 56, + "lexeme": "age", + "line": 57, "column": 10 }, { "type": "COLON", "lexeme": ":", - "line": 56, + "line": 57, + "column": 13 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 57, + "column": 14 + }, + { + "type": "IDENTIFIER", + "lexeme": "Optional", + "line": 57, + "column": 15 + }, + { + "type": "LEFT_BRACKET", + "lexeme": "[", + "line": 57, + "column": 23 + }, + { + "type": "IDENTIFIER", + "lexeme": "int", + "line": 57, + "column": 24 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 57, + "column": 27 + }, + { + "type": "WHERE", + "lexeme": "where", + "line": 57, + "column": 28 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 57, + "column": 33 + }, + { + "type": "LEFT_PAREN", + "lexeme": "(", + "line": 57, + "column": 34 + }, + { + "type": "NUMBER", + "lexeme": "0", + "line": 57, + "column": 35 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 57, + "column": 36 + }, + { + "type": "LESS_EQUAL", + "lexeme": "<=", + "line": 57, + "column": 37 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 57, + "column": 39 + }, + { + "type": "UNDERSCORE", + "lexeme": "_", + "line": 57, + "column": 40 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 57, + "column": 41 + }, + { + "type": "LESS", + "lexeme": "<", + "line": 57, + "column": 42 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 57, + "column": 43 + }, + { + "type": "NUMBER", + "lexeme": "150", + "line": 57, + "column": 44 + }, + { + "type": "RIGHT_PAREN", + "lexeme": ")", + "line": 57, + "column": 47 + }, + { + "type": "RIGHT_BRACKET", + "lexeme": "]", + "line": 57, + "column": 48 + }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 57, + "column": 49 + }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 58, + "column": 1 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 59, + "column": 1 + }, + { + "type": "COMMENT", + "lexeme": "// Property referencing a predicate", + "line": 59, + "column": 5 + }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 59, + "column": 40 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 60, + "column": 1 + }, + { + "type": "PROP", + "lexeme": "prop", + "line": 60, + "column": 5 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 60, + "column": 9 + }, + { + "type": "IDENTIFIER", + "lexeme": "height", + "line": 60, + "column": 10 + }, + { + "type": "COLON", + "lexeme": ":", + "line": 60, + "column": 16 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 60, + "column": 17 + }, + { + "type": "IDENTIFIER", + "lexeme": "float", + "line": 60, + "column": 18 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 60, + "column": 23 + }, + { + "type": "WHERE", + "lexeme": "where", + "line": 60, + "column": 24 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 60, + "column": 29 + }, + { + "type": "IDENTIFIER", + "lexeme": "StrictlyPositive", + "line": 60, + "column": 30 + }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 60, + "column": 46 + }, + { + "type": "NEWLINE", + "lexeme": "\n", + "line": 61, + "column": 1 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 62, + "column": 1 + }, + { + "type": "PROP", + "lexeme": "prop", + "line": 62, + "column": 5 + }, + { + "type": "WHITESPACE", + "lexeme": " ", + "line": 62, + "column": 9 + }, + { + "type": "IDENTIFIER", + "lexeme": "home", + "line": 62, + "column": 10 + }, + { + "type": "COLON", + "lexeme": ":", + "line": 62, "column": 14 }, { "type": "WHITESPACE", "lexeme": " ", - "line": 56, + "line": 62, "column": 15 }, { "type": "IDENTIFIER", "lexeme": "GeoLocation", - "line": 56, + "line": 62, "column": 16 }, { "type": "NEWLINE", "lexeme": "\n", - "line": 56, + "line": 62, "column": 27 }, { "type": "RIGHT_BRACE", "lexeme": "}", - "line": 57, + "line": 63, "column": 1 }, { "type": "NEWLINE", "lexeme": "\n", - "line": 57, + "line": 63, "column": 2 }, { "type": "EOF", "lexeme": "", - "line": 58, + "line": 64, "column": 1 } ], @@ -2548,27 +2626,8 @@ "name": "GeoLocation", "params": [], "type": { - "_type": "ComplexType", - "members": [ - { - "_type": "MemberStmt", - "kind": "PROPERTY", - "name": "lat", - "type": { - "_type": "NamedType", - "name": "Latitude" - } - }, - { - "_type": "MemberStmt", - "kind": "PROPERTY", - "name": "lon", - "type": { - "_type": "NamedType", - "name": "Longitude" - } - } - ] + "_type": "NamedType", + "name": "object" } }, { @@ -2578,93 +2637,76 @@ "members": [ { "_type": "MemberStmt", - "kind": "METHOD", - "name": "__sub__", + "kind": "PROPERTY", + "name": "lat", "type": { - "_type": "FunctionType", - "params": { - "_type": "ParamSpec", - "pos": [ - { - "name": null, - "type": { - "_type": "NamedType", - "name": "GeoLocation" - }, - "required": true - } - ], - "mixed": [], - "kw": [] - }, - "returns": { - "_type": "GenericType", - "type": { - "_type": "NamedType", - "name": "Difference" - }, - "args": [ - { - "_type": "NamedType", - "name": "GeoLocation" - } - ] - } + "_type": "NamedType", + "name": "Latitude" + } + }, + { + "_type": "MemberStmt", + "kind": "PROPERTY", + "name": "lon", + "type": { + "_type": "NamedType", + "name": "Longitude" } } ] }, { "_type": "TypeStmt", - "name": "Difference", - "params": [ - { - "name": "GeoLocation", - "bound": null - } - ], + "name": "GeoLocationDifference", + "params": [], "type": { - "_type": "ComplexType", - "members": [ - { - "_type": "MemberStmt", - "kind": "PROPERTY", - "name": "lat", - "type": { - "_type": "GenericType", - "type": { - "_type": "NamedType", - "name": "Difference" - }, - "args": [ - { - "_type": "NamedType", - "name": "Latitude" - } - ] - } - }, - { - "_type": "MemberStmt", - "kind": "PROPERTY", - "name": "lon", - "type": { - "_type": "GenericType", - "type": { - "_type": "NamedType", - "name": "Difference" - }, - "args": [ - { - "_type": "NamedType", - "name": "Longitude" - } - ] - } - } - ] + "_type": "NamedType", + "name": "object" } }, + { + "_type": "ExtendStmt", + "name": "GeoLocationDifference", + "params": [], + "members": [ + { + "_type": "MemberStmt", + "kind": "PROPERTY", + "name": "lat", + "type": { + "_type": "GenericType", + "type": { + "_type": "NamedType", + "name": "Difference" + }, + "args": [ + { + "_type": "NamedType", + "name": "Latitude" + } + ] + } + }, + { + "_type": "MemberStmt", + "kind": "PROPERTY", + "name": "lon", + "type": { + "_type": "GenericType", + "type": { + "_type": "NamedType", + "name": "Difference" + }, + "args": [ + { + "_type": "NamedType", + "name": "Longitude" + } + ] + } + } + ] + }, { "_type": "ExtendStmt", "name": "Latitude", @@ -2751,6 +2793,40 @@ } ] }, + { + "_type": "ExtendStmt", + "name": "GeoLocation", + "params": [], + "members": [ + { + "_type": "MemberStmt", + "kind": "METHOD", + "name": "__sub__", + "type": { + "_type": "FunctionType", + "params": { + "_type": "ParamSpec", + "pos": [ + { + "name": null, + "type": { + "_type": "NamedType", + "name": "GeoLocation" + }, + "required": true + } + ], + "mixed": [], + "kw": [] + }, + "returns": { + "_type": "NamedType", + "name": "GeoLocationDifference" + } + } + } + ] + }, { "_type": "PredicateStmt", "name": "Positive", @@ -2914,87 +2990,93 @@ "name": "Person", "params": [], "type": { - "_type": "ComplexType", - "members": [ - { - "_type": "MemberStmt", - "kind": "PROPERTY", - "name": "name", + "_type": "NamedType", + "name": "object" + } + }, + { + "_type": "ExtendStmt", + "name": "Person", + "params": [], + "members": [ + { + "_type": "MemberStmt", + "kind": "PROPERTY", + "name": "name", + "type": { + "_type": "NamedType", + "name": "str" + } + }, + { + "_type": "MemberStmt", + "kind": "PROPERTY", + "name": "age", + "type": { + "_type": "GenericType", "type": { "_type": "NamedType", - "name": "str" - } - }, - { - "_type": "MemberStmt", - "kind": "PROPERTY", - "name": "age", - "type": { - "_type": "GenericType", - "type": { - "_type": "NamedType", - "name": "Optional" - }, - "args": [ - { - "_type": "ConstraintType", - "type": { - "_type": "NamedType", - "name": "int" - }, - "constraint": { - "_type": "GroupingExpr", - "expr": { + "name": "Optional" + }, + "args": [ + { + "_type": "ConstraintType", + "type": { + "_type": "NamedType", + "name": "int" + }, + "constraint": { + "_type": "GroupingExpr", + "expr": { + "_type": "BinaryExpr", + "left": { "_type": "BinaryExpr", "left": { - "_type": "BinaryExpr", - "left": { - "_type": "LiteralExpr", - "value": 0 - }, - "operator": "<=", - "right": { - "_type": "WildcardExpr" - } - }, - "operator": "<", - "right": { "_type": "LiteralExpr", - "value": 150 + "value": 0 + }, + "operator": "<=", + "right": { + "_type": "WildcardExpr" } + }, + "operator": "<", + "right": { + "_type": "LiteralExpr", + "value": 150 } } } - ] - } - }, - { - "_type": "MemberStmt", - "kind": "PROPERTY", - "name": "height", - "type": { - "_type": "ConstraintType", - "type": { - "_type": "NamedType", - "name": "float" - }, - "constraint": { - "_type": "VariableExpr", - "name": "StrictlyPositive" } - } - }, - { - "_type": "MemberStmt", - "kind": "PROPERTY", - "name": "home", + ] + } + }, + { + "_type": "MemberStmt", + "kind": "PROPERTY", + "name": "height", + "type": { + "_type": "ConstraintType", "type": { "_type": "NamedType", - "name": "GeoLocation" + "name": "float" + }, + "constraint": { + "_type": "VariableExpr", + "name": "StrictlyPositive" } } - ] - } + }, + { + "_type": "MemberStmt", + "kind": "PROPERTY", + "name": "home", + "type": { + "_type": "NamedType", + "name": "GeoLocation" + } + } + ] } ], "errors": [] diff --git a/tests/serializer/midas.py b/tests/serializer/midas.py index 13fcbaa..599482b 100644 --- a/tests/serializer/midas.py +++ b/tests/serializer/midas.py @@ -4,11 +4,9 @@ from midas.ast.midas import ( AliasStmt, BinaryExpr, CallExpr, - ComplexType, ConstraintType, Expr, ExtendStmt, - ExtensionType, FrameType, FunctionType, GenericType, @@ -172,12 +170,6 @@ class MidasAstJsonSerializer( "constraint": type.constraint.accept(self), } - def visit_complex_type(self, type: ComplexType) -> dict: - return { - "_type": "ComplexType", - "members": self._serialize_list(type.members), - } - def visit_function_type(self, type: FunctionType) -> dict: return { "_type": "FunctionType", @@ -200,13 +192,6 @@ class MidasAstJsonSerializer( "required": param.required, } - def visit_extension_type(self, type: ExtensionType) -> dict: - return { - "_type": "ExtensionType", - "base": type.base.accept(self), - "extension": type.extension.accept(self), - } - def visit_frame_type(self, type: FrameType) -> dict: return { "_type": "FrameType",