Skip to content

Commit

Permalink
Axiom: Argument is now optional
Browse files Browse the repository at this point in the history
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
  • Loading branch information
tonydamage committed May 13, 2020
1 parent 4c0f8bd commit 272745a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
Expand Up @@ -20,7 +20,7 @@ public enum BasicStatementRule implements StatementRule<AxiomIdentifier> {
@Override
public void apply(StatementRuleContext<AxiomIdentifier> rule) throws AxiomSemanticException {
Optional<AxiomItemDefinition> argument = rule.typeDefinition().argument();
if(argument.isPresent()) {
if(argument.isPresent() && rule.optionalValue().isPresent()) {
rule.apply(ctx -> ctx.createEffectiveChild(argument.get().name(), ctx.requireValue()));
}
}
Expand Down
Expand Up @@ -32,4 +32,6 @@ public interface Action<V> {

AxiomTypeDefinition typeDefinition();

Optional<V> optionalValue();

}
Expand Up @@ -99,6 +99,11 @@ public AxiomTypeDefinition typeDefinition() {
return context.definition().type();
}

@Override
public Optional<V> optionalValue() {
return context.optionalValue();
}

@Override
public RuleErrorMessage error(String format, Object... arguments) {
return RuleErrorMessage.from(context.startLocation(), format, arguments);
Expand Down
7 changes: 1 addition & 6 deletions infra/axiom/src/main/resources/axiom-lang.axiom
Expand Up @@ -98,10 +98,5 @@ model axiom-lang {
}
}

type AxiomTypeReference {
// extends AxiomReference;
// item targetType {
// value AxiomTypeDefinition;
// }
}
type AxiomTypeReference;
}
7 changes: 6 additions & 1 deletion infra/axiom/src/test/resources/base-example.axiom
Expand Up @@ -14,9 +14,9 @@ model model-header {
version "0.0.1";

type string;
type PolyString;
type Address;
type Link;
type PolyString;

type Example {
documentation """
Expand Down Expand Up @@ -45,4 +45,9 @@ model model-header {
maxOccurs unbounded;
}
}

object {
name User2;
itemName user;
}
}

0 comments on commit 272745a

Please sign in to comment.