==================
Concept declaration
==================

concept Cup;

---

(source_file
  (declaration
    (concept_declaration
      name: (identifier))))

==================
Multiple concept declarations
==================

concept Cup;
concept Customer;
concept Vendor;

---

(source_file
  (declaration
    (concept_declaration
      name: (identifier)))
  (declaration
    (concept_declaration
      name: (identifier)))
  (declaration
    (concept_declaration
      name: (identifier))))

==================
Sub-concept - enum form
==================

sub_concept Cup.Size {
    Small,
    Medium,
    Large
}

---

(source_file
  (declaration
    (sub_concept
      parent: (identifier)
      name: (identifier)
      body: (sub_concept_enum_body
        (identifier)
        (identifier)
        (identifier)))))

==================
Sub-concept - record form with any
==================

sub_concept Vendor.Inventory {
    Bread: any,
    Pastries: any,
    Cakes: any,
    Cup: any
}

---

(source_file
  (declaration
    (sub_concept
      parent: (identifier)
      name: (identifier)
      body: (sub_concept_record_body
        (sub_concept_field
          name: (identifier)
          type: (any_type))
        (sub_concept_field
          name: (identifier)
          type: (any_type))
        (sub_concept_field
          name: (identifier)
          type: (any_type))
        (sub_concept_field
          name: (identifier)
          type: (any_type))))))

==================
Sub-concept - record form with typed fields
==================

sub_concept Vendor.Inventory {
    Bread: any,
    Pastries: Number
}

---

(source_file
  (declaration
    (sub_concept
      parent: (identifier)
      name: (identifier)
      body: (sub_concept_record_body
        (sub_concept_field
          name: (identifier)
          type: (any_type))
        (sub_concept_field
          name: (identifier)
          type: (identifier))))))

==================
Concept comparison with any conditions
==================

concept_comparison NotInterested {
    NotInterested: {
        Cup.Size: any,
        Cup.Type: any,
        Cup.Color: any
    }
}

---

(source_file
  (declaration
    (concept_comparison
      name: (identifier)
      (variant_pattern
        name: (identifier)
        (field_condition
          sub_concept: (dotted_path
            (identifier)
            (identifier))
          condition: (condition_expr
            (any_type)))
        (field_condition
          sub_concept: (dotted_path
            (identifier)
            (identifier))
          condition: (condition_expr
            (any_type)))
        (field_condition
          sub_concept: (dotted_path
            (identifier)
            (identifier))
          condition: (condition_expr
            (any_type)))))))

==================
Concept comparison with is conditions
==================

concept_comparison Interest {
    Interested: {
        Cup.Type: Cup.Type is Glass or Cup.Type is Plastic,
        Cup.Color: Cup.Color is Red
    }
}

---

(source_file
  (declaration
    (concept_comparison
      name: (identifier)
      (variant_pattern
        name: (identifier)
        (field_condition
          sub_concept: (dotted_path
            (identifier)
            (identifier))
          condition: (condition_expr
            (is_condition
              (dotted_path
                (identifier)
                (identifier))
              (identifier)
              (dotted_path
                (identifier)
                (identifier))
              (identifier))))
        (field_condition
          sub_concept: (dotted_path
            (identifier)
            (identifier))
          condition: (condition_expr
            (is_condition
              (dotted_path
                (identifier)
                (identifier))
              (identifier))))))))

==================
Concept comparison with multiple variants
==================

concept_comparison FoodQuality {
    Excellent: {
        Food.Freshness: Food.Freshness is Fresh
    },
    Poor: {
        Food.Freshness: Food.Freshness is Stale or Food.Freshness is Spoiled
    }
}

---

(source_file
  (declaration
    (concept_comparison
      name: (identifier)
      (variant_pattern
        name: (identifier)
        (field_condition
          sub_concept: (dotted_path
            (identifier)
            (identifier))
          condition: (condition_expr
            (is_condition
              (dotted_path
                (identifier)
                (identifier))
              (identifier)))))
      (variant_pattern
        name: (identifier)
        (field_condition
          sub_concept: (dotted_path
            (identifier)
            (identifier))
          condition: (condition_expr
            (is_condition
              (dotted_path
                (identifier)
                (identifier))
              (identifier)
              (dotted_path
                (identifier)
                (identifier))
              (identifier))))))))

==================
Template with species extension
==================

template Person: Human {
    age: 0..100
    name: ""
}

---

(source_file
  (declaration
    (template
      name: (identifier)
      species: (identifier)
      (field
        name: (dotted_path (identifier))
        value: (value (range (integer) (integer))))
      (field
        name: (dotted_path (identifier))
        value: (value (string))))))

==================
Full type system example
==================

concept Cup;

sub_concept Cup.Size {
    Small,
    Medium,
    Large
}

sub_concept Cup.Type {
    Ceramic,
    Glass,
    Plastic
}

concept_comparison CupPreference {
    Preferred: {
        Cup.Size: any,
        Cup.Type: Cup.Type is Glass or Cup.Type is Ceramic
    },
    Avoided: {
        Cup.Size: any,
        Cup.Type: Cup.Type is Plastic
    }
}

---

(source_file
  (declaration
    (concept_declaration
      name: (identifier)))
  (declaration
    (sub_concept
      parent: (identifier)
      name: (identifier)
      body: (sub_concept_enum_body
        (identifier)
        (identifier)
        (identifier))))
  (declaration
    (sub_concept
      parent: (identifier)
      name: (identifier)
      body: (sub_concept_enum_body
        (identifier)
        (identifier)
        (identifier))))
  (declaration
    (concept_comparison
      name: (identifier)
      (variant_pattern
        name: (identifier)
        (field_condition
          sub_concept: (dotted_path
            (identifier)
            (identifier))
          condition: (condition_expr
            (any_type)))
        (field_condition
          sub_concept: (dotted_path
            (identifier)
            (identifier))
          condition: (condition_expr
            (is_condition
              (dotted_path
                (identifier)
                (identifier))
              (identifier)
              (dotted_path
                (identifier)
                (identifier))
              (identifier)))))
      (variant_pattern
        name: (identifier)
        (field_condition
          sub_concept: (dotted_path
            (identifier)
            (identifier))
          condition: (condition_expr
            (any_type)))
        (field_condition
          sub_concept: (dotted_path
            (identifier)
            (identifier))
          condition: (condition_expr
            (is_condition
              (dotted_path
                (identifier)
                (identifier))
              (identifier))))))))
