24 package org.lightjason.agentspeak.grammar;
26 import com.google.common.collect.LinkedHashMultimap;
27 import com.google.common.collect.Multimap;
28 import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;
29 import org.apache.commons.lang3.tuple.ImmutablePair;
30 import org.apache.commons.lang3.tuple.Pair;
89 import javax.annotation.Nonnull;
90 import java.text.MessageFormat;
91 import java.util.Collection;
92 import java.util.Collections;
93 import java.util.HashSet;
94 import java.util.LinkedHashSet;
95 import java.util.LinkedList;
96 import java.util.List;
98 import java.util.Objects;
100 import java.util.logging.Logger;
101 import java.util.stream.Collectors;
110 @SuppressWarnings( {
"all",
"warnings",
"unchecked",
"unused",
"cast"} )
124 private final Set<ILiteral> m_initialbeliefs =
new LinkedHashSet<>();
128 private final Set<IPlan> m_plans =
new HashSet<>();
132 private final Multimap<IPath, IRule> m_rules = LinkedHashMultimap.create();
145 m_actions = p_actions.stream().collect( Collectors.toMap( i -> i.name(), i -> i ) );
146 LOGGER.info( MessageFormat.format(
"create parser with actions & rules : {0} / {1}", m_actions.keySet(), m_rules.keySet() ) );
155 public final Object
visitAgent(
final AgentParser.AgentContext p_context )
157 return this.visitChildren( p_context );
165 p_context.belief().stream().map( i -> (
ILiteral) this.visitBelief( i ) ).forEach( m_initialbeliefs::add );
166 LOGGER.info( MessageFormat.format(
"parsed initial beliefs: {0}", m_initialbeliefs ) );
175 m_initialgoal =
CLiteral.
from( (String) this.visitAtom( p_context.atom() ) );
176 LOGGER.info( MessageFormat.format(
"parsed initial-goal: {0}", m_initialgoal ) );
186 public final Object
visitBelief(
final AgentParser.BeliefContext p_context )
188 return this.visitLiteral( p_context.literal() );
194 public final Object
visitPlans(
final AgentParser.PlansContext p_context )
196 if ( Objects.isNull( p_context.plan() ) )
199 p_context.plan().stream().forEach( i -> ( (List<IPlan>) this.visitPlan( i ) ).stream().forEach( j -> m_plans.add( j ) ) );
200 LOGGER.info( MessageFormat.format(
"parsed plans: {0}", m_plans ) );
210 p_context.logicrule().stream()
211 .map( i -> (
IRule) this.visitLogicrulePlaceHolder( i ) )
212 .forEach( i -> m_rules.put( i.identifier().fqnfunctor(), i ) );
214 final Multimap<IPath, IRule> l_rules = LinkedHashMultimap.create();
215 p_context.logicrule().stream()
216 .flatMap( i -> ( (List<IRule>) this.visitLogicrule( i ) ).stream() )
217 .forEach( i -> l_rules.put( i.identifier().fqnfunctor(), i ) );
221 l_rules.values().stream()
222 .map( i -> i.replaceplaceholder( l_rules ) )
223 .forEach( i -> m_rules.put( i.identifier().fqnfunctor(), i ) );
225 LOGGER.info( MessageFormat.format(
"parsed rules: {0}", m_rules.values() ) );
230 public final Object
visitLogicrule(
final AgentParser.LogicruleContext p_context )
232 final ILiteral l_literal = (
ILiteral) this.visitLiteral( p_context.literal() );
233 return p_context.logicalruledefinition().stream()
234 .map( i ->
new CRule( (
ILiteral) l_literal.
deepcopy(), (List<IExecution>) this.visitLogicalruledefinition( i ) ) )
235 .collect( Collectors.toList() );
241 return this.visitBody( p_context.body() );
245 public final Object
visitPlan(
final AgentParser.PlanContext p_context )
247 final Set<IAnnotation<?>> l_annotation = (Set<IAnnotation<?>>) this.visitAnnotations( p_context.annotations() );
249 (
ITrigger.
EType)
this.visitPlan_trigger( p_context.plan_trigger() ),
250 (
ILiteral) this.visitLiteral( p_context.literal() )
253 return p_context.plandefinition()
257 final Pair<IExpression, List<IExecution>> l_content = (Pair<IExpression, List<IExecution>>) this.visitPlandefinition( i );
258 return new CPlan( l_trigger, l_content.getLeft(), l_content.getRight(), l_annotation );
260 .collect( Collectors.toList() );
266 return new ImmutablePair<IExpression, List<IExecution>>(
267 Objects.isNull( p_context.expression() )
269 : (
IExpression) this.visitExpression( p_context.expression() ),
270 (List<IExecution>) this.visitBody( p_context.body() )
277 if ( ( Objects.isNull( p_context ) ) || ( p_context.isEmpty() ) )
278 return Collections.emptySet();
281 final Set<IAnnotation<?>> l_annotation =
new HashSet<>();
283 if ( Objects.nonNull( p_context.annotation_atom() ) )
284 p_context.annotation_atom().stream().map( i -> (
IAnnotation<?>) this.visitAnnotation_atom( i ) ).forEach( l_annotation::add );
286 if ( Objects.nonNull( p_context.annotation_literal() ) )
287 p_context.annotation_literal().stream().map( i -> (
IAnnotation<?>) this.visitAnnotation_literal( i ) ).forEach( l_annotation::add );
289 return l_annotation.isEmpty() ? Collections.emptySet() : l_annotation;
295 if ( Objects.nonNull( p_context.ATOMIC() ) )
298 if ( Objects.nonNull( p_context.PARALLEL() ) )
307 return this.visitChildren( p_context );
313 if ( Objects.nonNull( p_context.number() ) )
316 (String) this.visitVariableatom( p_context.variableatom() ),
317 ( (Number) this.visitNumber( p_context.number() ) ).doubleValue()
320 if ( Objects.nonNull( p_context.STRING() ) )
323 (String) this.visitVariableatom( p_context.variableatom() ),
324 stringvalue( p_context.STRING().getText() )
333 return this.visitChildren( p_context );
361 public final Object
visitBody(
final AgentParser.BodyContext p_context )
364 return p_context.body_formula().stream()
365 .filter( i -> Objects.nonNull( i ) )
366 .map( i -> this.visitBody_formula( i ) )
370 .collect( Collectors.toList() );
376 return this.visitChildren( p_context );
384 if ( Objects.isNull( p_context.repair_formula() ) )
385 return this.visitChildren( p_context );
389 if ( Objects.nonNull( p_context.executable_term() ) )
391 (
IExecution) this.visitExecutable_term( p_context.executable_term() ),
392 (
IExecution) this.visitRepair_formula( p_context.repair_formula() )
395 if ( Objects.nonNull( p_context.test_action() ) )
397 (
IExecution) this.visitTest_action( p_context.test_action() ),
398 (
IExecution) this.visitRepair_formula( p_context.repair_formula() )
401 if ( Objects.nonNull( p_context.achievement_goal_action() ) )
403 (
IExecution) this.visitAchievement_goal_action( p_context.achievement_goal_action() ),
404 (
IExecution) this.visitRepair_formula( p_context.repair_formula() )
413 final Object l_constraint = this.visitUnification_constraint( p_context.unification_constraint() );
417 p_context.AT() != null,
418 (
ILiteral) this.visitLiteral( p_context.literal() ),
419 (IExpression) l_constraint
424 p_context.AT() != null,
425 (
ILiteral) this.visitLiteral( p_context.literal() ),
426 (IVariable<?>) l_constraint
429 return new CDefaultUnify( p_context.AT() != null, (
ILiteral) this.visitLiteral( p_context.literal() ) );
435 if ( Objects.isNull( p_context ) )
438 if ( Objects.nonNull( p_context.expression() ) )
439 return this.visitExpression( p_context.expression() );
441 if ( Objects.nonNull( p_context.variable() ) )
442 return this.visitVariable( p_context.variable() );
450 if ( Objects.nonNull( p_context.body_formula() ) )
452 final LinkedList<IExecution> l_statement =
new LinkedList<>();
453 l_statement.add( (
IExecution) this.visitBody_formula( p_context.body_formula() ) );
457 return this.visitBody( p_context.body() );
461 public final Object
visitLambda(
final AgentParser.LambdaContext p_context )
463 if ( Objects.nonNull( p_context.lambda_return() ) )
465 p_context.AT() != null,
466 (
IExecution) this.visitLambda_initialization( p_context.lambda_initialization() ),
467 (
IVariable<?>) this.visitVariable( p_context.variable() ),
468 (
IVariable<?>) this.visitLambda_return( p_context.lambda_return() ),
469 (List<IExecution>) this.visitBlock_formula( p_context.block_formula() )
473 p_context.AT() != null,
474 (
IExecution) this.visitLambda_initialization( p_context.lambda_initialization() ),
475 (
IVariable<?>) this.visitVariable( p_context.variable() ),
476 (List<IExecution>) this.visitBlock_formula( p_context.block_formula() )
483 if ( Objects.nonNull( p_context.variable() ) )
484 return new CRawAction<>( this.visitVariable( p_context.variable() ) );
486 if ( Objects.nonNull( p_context.literal() ) )
495 return this.visitVariable( p_context.variable() );
501 if ( Objects.nonNull( p_context.STRING() ) )
502 return new CRawAction<>( stringvalue( p_context.STRING().getText() ) );
503 if ( Objects.nonNull( p_context.number() ) )
504 return new CRawAction<>( this.visitNumber( p_context.number() ) );
505 if ( Objects.nonNull( p_context.LOGICALVALUE() ) )
506 return new CRawAction<>( logicalvalue( p_context.LOGICALVALUE().getText() ) );
508 if ( Objects.nonNull( p_context.executable_action() ) )
509 return this.visitExecutable_action( p_context.executable_action() );
510 if ( Objects.nonNull( p_context.executable_rule() ) )
511 return this.visitExecutable_rule( p_context.executable_rule() );
513 if ( Objects.nonNull( p_context.expression() ) )
514 return this.visitExpression( p_context.expression() );
515 if ( Objects.nonNull( p_context.ternary_operation() ) )
516 return this.visitTernary_operation( p_context.ternary_operation() );
524 return this.visitChildren( p_context );
531 (
IVariable<?>) this.visitVariable( p_context.variable() ),
532 (
IExecution) this.visitExecutable_term( p_context.executable_term() )
540 p_context.variablelist().variable().stream().map( i -> (
IVariable<?>) this.visitVariable( i ) )
541 .collect( Collectors.toList() ),
542 (
IExecution) this.visitExecutable_term( p_context.executable_term() )
549 switch ( p_context.UNARYOPERATOR().getText() )
566 final ITerm l_rhs = p_context.variable().size() == 2
568 :
CRawTerm.
from(
this.visitNumber( p_context.number() ) );
578 if ( Objects.nonNull( p_context.literal() ) )
581 if ( Objects.nonNull( p_context.variable_evaluate() ) )
583 (
IVariableEvaluate) this.visitVariable_evaluate( p_context.variable_evaluate() ),
584 Objects.nonNull( p_context.DOUBLEEXCLAMATIONMARK() )
594 (
IExpression) this.visitExpression( p_context.expression() ),
595 (
IExecution) this.visitTernary_operation_true( p_context.ternary_operation_true() ),
596 (
IExecution) this.visitTernary_operation_false( p_context.ternary_operation_false() )
603 return this.visitExecutable_term( p_context.executable_term() );
609 return this.visitExecutable_term( p_context.executable_term() );
616 return Objects.nonNull( p_context.DOLLAR() )
624 if ( Objects.nonNull( p_context.PLUS() ) )
627 if ( Objects.nonNull( p_context.MINUS() ) )
637 p_context.variablelist().variable().stream().map( i -> (
IVariable<?>) this.visitVariable( i ) ).collect( Collectors.toList() ),
638 (
ITerm) ( Objects.nonNull( p_context.literal() ) ? this.visitLiteral( p_context.literal() ) : this.visitVariable( p_context.variable() ) )
648 public final Object
visitLiteral(
final AgentParser.LiteralContext p_context )
651 Objects.nonNull( p_context.AT() ),
652 Objects.nonNull( p_context.STRONGNEGATION() ),
653 CPath.
from(
this.visitAtom( p_context.atom() ).toString() ),
654 (Collection<ITerm>) this.visitTermlist( p_context.termlist() )
659 public final Object
visitTerm(
final AgentParser.TermContext p_context )
661 if ( Objects.nonNull( p_context.STRING() ) )
662 return stringvalue( p_context.STRING().getText() );
663 if ( Objects.nonNull( p_context.number() ) )
664 return this.visitNumber( p_context.number() );
665 if ( Objects.nonNull( p_context.LOGICALVALUE() ) )
666 return logicalvalue( p_context.LOGICALVALUE().getText() );
668 if ( Objects.nonNull( p_context.literal() ) )
669 return this.visitLiteral( p_context.literal() );
670 if ( Objects.nonNull( p_context.variable() ) )
671 return this.visitVariable( p_context.variable() );
673 if ( Objects.nonNull( p_context.termlist() ) )
674 return this.visitTermlist( p_context.termlist() );
675 if ( Objects.nonNull( p_context.expression() ) )
676 return this.visitExpression( p_context.expression() );
677 if ( Objects.nonNull( p_context.ternary_operation() ) )
678 return this.visitTernary_operation( p_context.ternary_operation() );
684 public final Object
visitTermlist(
final AgentParser.TermlistContext p_context )
686 if ( ( Objects.isNull( p_context ) ) || ( p_context.isEmpty() ) )
687 return Collections.<
ITerm>emptyList();
689 return p_context.term().stream()
690 .map( i -> this.visitTerm( i ) )
691 .filter( i -> Objects.nonNull( i ) )
693 .collect( Collectors.toList() );
699 return this.visitChildren( p_context );
708 public final Object
visitNumber(
final AgentParser.NumberContext p_context )
710 if ( Objects.nonNull( p_context.CONSTANTNUMBER() ) )
711 return numericonstant( p_context.CONSTANTNUMBER().getText() );
713 final Number l_value = (Number) this.visitChildren( p_context );
714 return Objects.nonNull( p_context.MINUS() )
715 ? -1 * l_value.doubleValue()
716 : l_value.doubleValue();
722 return Double.valueOf( p_context.getText() );
726 public final Object
visitAtom(
final AgentParser.AtomContext p_context )
728 return p_context.getText();
732 public final Object
visitVariable(
final AgentParser.VariableContext p_context )
734 return Objects.isNull( p_context.AT() )
735 ?
new CVariable<>( (String) this.visitVariableatom( p_context.variableatom() ) )
736 :
new CMutexVariable<>( (String) this.visitVariableatom( p_context.variableatom() ) );
742 return p_context.getText();
749 if ( Objects.nonNull( p_context.expression_bracket() ) )
750 return this.visitExpression_bracket( p_context.expression_bracket() );
755 (
IExpression)
this.visitExpression_logical_and( p_context.expression_logical_and() ),
756 Objects.nonNull( p_context.expression() )
757 ? p_context.expression().stream().map( i -> (
IExpression) this.visitExpression( i ) ).collect( Collectors.toList() )
758 : Collections.emptyList()
765 return this.visitExpression( p_context.expression() );
773 (
IExpression)
this.visitExpression_logical_xor( p_context.expression_logical_xor() ),
774 Objects.nonNull( p_context.expression() )
775 ? p_context.expression().stream().map( i -> (
IExpression) this.visitExpression( i ) ).collect( Collectors.toList() )
776 : Collections.emptyList()
783 if ( Objects.nonNull( p_context.expression_logical_element() ) )
786 (
IExpression)
this.visitExpression_logical_element( p_context.expression_logical_element() ),
787 Objects.nonNull( p_context.expression() )
788 ? p_context.expression().stream().map( i -> (
IExpression) this.visitExpression( i ) ).collect( Collectors.toList() )
789 : Collections.emptyList()
792 if ( Objects.nonNull( p_context.expression_logical_negation() ) )
793 return this.visitExpression_logical_negation( p_context.expression_logical_negation() );
795 if ( Objects.nonNull( p_context.expression_numeric() ) )
796 return this.visitExpression_numeric( p_context.expression_numeric() );
810 if ( Objects.nonNull( p_context.LOGICALVALUE() ) )
811 return new CAtom( logicalvalue( p_context.LOGICALVALUE().getText() ) );
813 if ( Objects.nonNull( p_context.variable() ) )
814 return new CAtom( this.visitVariable( p_context.variable() ) );
816 if ( Objects.nonNull( p_context.unification() ) )
819 if ( Objects.nonNull( p_context.executable_action() ) )
822 if ( Objects.nonNull( p_context.executable_rule() ) )
831 if ( Objects.isNull( p_context.expression_numeric() ) )
832 return this.visitExpression_numeric_relation( p_context.expression_numeric_relation() );
834 if ( Objects.nonNull( p_context.EQUAL() ) )
837 (
IExpression)
this.visitExpression_numeric_relation( p_context.expression_numeric_relation() ),
838 (
IExpression) this.visitExpression_numeric( p_context.expression_numeric() )
841 if ( Objects.nonNull( p_context.NOTEQUAL() ) )
844 (
IExpression)
this.visitExpression_numeric_relation( p_context.expression_numeric_relation() ),
845 (
IExpression) this.visitExpression_numeric( p_context.expression_numeric() )
854 if ( Objects.isNull( p_context.expression_numeric() ) )
855 return this.visitExpression_numeric_additive( p_context.expression_numeric_additive() );
857 if ( Objects.nonNull( p_context.GREATER() ) )
860 (
IExpression)
this.visitExpression_numeric_additive( p_context.expression_numeric_additive() ),
861 (
IExpression) this.visitExpression_numeric( p_context.expression_numeric() )
864 if ( Objects.nonNull( p_context.GREATEREQUAL() ) )
867 (
IExpression)
this.visitExpression_numeric_additive( p_context.expression_numeric_additive() ),
868 (
IExpression) this.visitExpression_numeric( p_context.expression_numeric() )
871 if ( Objects.nonNull( p_context.LESS() ) )
874 (
IExpression)
this.visitExpression_numeric_additive( p_context.expression_numeric_additive() ),
875 (
IExpression) this.visitExpression_numeric( p_context.expression_numeric() )
878 if ( Objects.nonNull( p_context.LESSEQUAL() ) )
881 (
IExpression)
this.visitExpression_numeric_additive( p_context.expression_numeric_additive() ),
882 (
IExpression) this.visitExpression_numeric( p_context.expression_numeric() )
891 if ( Objects.isNull( p_context.expression_numeric() ) )
892 return this.visitExpression_numeric_multiplicative( p_context.expression_numeric_multiplicative() );
894 if ( Objects.nonNull( p_context.PLUS() ) )
897 (
IExpression)
this.visitExpression_numeric_multiplicative( p_context.expression_numeric_multiplicative() ),
898 (
IExpression) this.visitExpression_numeric( p_context.expression_numeric() )
901 if ( Objects.nonNull( p_context.MINUS() ) )
904 (
IExpression)
this.visitExpression_numeric_multiplicative( p_context.expression_numeric_multiplicative() ),
905 (
IExpression) this.visitExpression_numeric( p_context.expression_numeric() )
914 if ( Objects.isNull( p_context.expression_numeric() ) )
915 return this.visitExpression_numeric_power( p_context.expression_numeric_power() );
917 if ( Objects.nonNull( p_context.MULTIPLY() ) )
920 (
IExpression)
this.visitExpression_numeric_power( p_context.expression_numeric_power() ),
921 (
IExpression) this.visitExpression_numeric( p_context.expression_numeric() )
924 if ( Objects.nonNull( p_context.SLASH() ) )
927 (
IExpression)
this.visitExpression_numeric_power( p_context.expression_numeric_power() ),
928 (
IExpression) this.visitExpression_numeric( p_context.expression_numeric() )
931 if ( Objects.nonNull( p_context.MODULO() ) )
934 (
IExpression)
this.visitExpression_numeric_power( p_context.expression_numeric_power() ),
935 (
IExpression) this.visitExpression_numeric( p_context.expression_numeric() )
944 if ( Objects.isNull( p_context.expression_numeric() ) )
945 return this.visitExpression_numeric_element( p_context.expression_numeric_element() );
949 (
IExpression)
this.visitExpression_numeric_element( p_context.expression_numeric_element() ),
950 (
IExpression) this.visitExpression_numeric( p_context.expression_numeric() )
957 if ( Objects.nonNull( p_context.number() ) )
958 return new CAtom( this.visitNumber( p_context.number() ) );
960 if ( Objects.nonNull( p_context.variable() ) )
961 return new CAtom( this.visitVariable( p_context.variable() ) );
963 if ( Objects.nonNull( p_context.executable_action() ) )
966 if ( Objects.nonNull( p_context.executable_rule() ) )
981 if ( Objects.nonNull( p_context.literal() ) )
984 if ( Objects.nonNull( p_context.variable_evaluate() ) )
994 (
IVariable<?>) this.visitVariable( p_context.variable() ),
995 (List<ITerm>) this.visitTermlist( p_context.termlist() )
1024 if ( Objects.nonNull( l_constant ) )
1038 return ( !p_value.isEmpty() ) && ( (
"true".equals( p_value ) ) || (
"success".equals( p_value ) ) );
1049 return p_value.length() < 3 ?
"" : p_value.substring( 1, p_value.length() - 1 );
1061 return m_initialbeliefs;
1075 return new HashSet<>( m_rules.values() );
1081 return m_initialgoal;
final Object visitInitial_beliefs(final AgentParser.Initial_beliefsContext p_context)
static Number numericonstant( @Nonnull final String p_value)
returns the value of a numeric constant
final Object visitRepair_formula(final AgentParser.Repair_formulaContext p_context)
final Object visitPlandefinition(final AgentParser.PlandefinitionContext p_context)
final Object visitPlan(final AgentParser.PlanContext p_context)
final Object visitBelief_action(final AgentParser.Belief_actionContext p_context)
final Object visitAssignment_expression_singlevariable(final AgentParser.Assignment_expression_singlevariableContext p_context)
final Object visitPlan_trigger(final AgentParser.Plan_triggerContext p_context)
final Object visitLambda_initialization(final AgentParser.Lambda_initializationContext p_context)
final Object visitLogicrules(final AgentParser.LogicrulesContext p_context)
final Object visitPlans(final AgentParser.PlansContext p_context)
IExpression EMPTY
empty expression, is always true
final Object visitPlan_goal_trigger(final AgentParser.Plan_goal_triggerContext p_context)
proxy action to encapsulate all actions
lambda expression definition
placeholder rule to define correct rule referencing
final Set< IPlan > plans()
get a multimap with event-plan matching
final Object visitDeconstruct_expression(final AgentParser.Deconstruct_expressionContext p_context)
final Object visitLambda(final AgentParser.LambdaContext p_context)
illegal argument exception
internal execution interface
final Object visitTermlist(final AgentParser.TermlistContext p_context)
multiplicative binary expression
final Object visitTernary_operation_false(final AgentParser.Ternary_operation_falseContext p_context)
final Object visitAssignment_expression_multivariable(final AgentParser.Assignment_expression_multivariableContext p_context)
final Object visitExecutable_rule(final AgentParser.Executable_ruleContext p_context)
final Object visitExecutable_term(final AgentParser.Executable_termContext p_context)
interface of logical rule
final Object visitExpression_numeric_element(final AgentParser.Expression_numeric_elementContext p_context)
final Object visitAssignment_expression(final AgentParser.Assignment_expressionContext p_context)
final Object visitExpression_bracket(final AgentParser.Expression_bracketContext p_context)
static IPath from( @Nonnull final String p_string)
factor method to build path
final Object visitVariable(final AgentParser.VariableContext p_context)
exception for parsing error
static< T > String languagestring(final T p_source, final String p_label, final Object... p_parameter)
returns the language depend string on any object
class to create a path structure
encapsulate class for any non-executable data type e.g.
final Object visitExpression(final AgentParser.ExpressionContext p_context)
final Object visitAtom(final AgentParser.AtomContext p_context)
final Object visitTest_action(final AgentParser.Test_actionContext p_context)
final Object visitTernary_operation(final AgentParser.Ternary_operationContext p_context)
final Object visitExpression_logical_and(final AgentParser.Expression_logical_andContext p_context)
final Map< IPath, IAction > m_actions
map with action definition
final Object visitExpression_numeric_additive(final AgentParser.Expression_numeric_additiveContext p_context)
final Object visitVariableatom(final AgentParser.VariableatomContext p_context)
final Object visitBinary_expression(final AgentParser.Binary_expressionContext p_context)
numerical relation expression
visitor interface of the abstract-syntax-tree (AST) for an agent
comparable binary expression
final Object visitUnification(final AgentParser.UnificationContext p_context)
final Set< IRule > rules()
returns the rules / principles
default abstract-syntax-tree (AST) visitor for agent scripts
external action interface
final Object visitUnary_expression(final AgentParser.Unary_expressionContext p_context)
achievement-goal action based on a literal
final Object visitVariablelist(final AgentParser.VariablelistContext p_context)
final Object visitExpression_numeric(final AgentParser.Expression_numericContext p_context)
final Object visitTernary_operation_true(final AgentParser.Ternary_operation_trueContext p_context)
static Logger logger(final Class<?> p_class)
returns a logger instance
final Object visitExpression_logical_xor(final AgentParser.Expression_logical_xorContext p_context)
final Object visitLambda_return(final AgentParser.Lambda_returnContext p_context)
static String stringvalue( @Nonnull final String p_value)
create a string value without quotes
encpasulating any execution context
final Object visitAchievement_goal_action(final AgentParser.Achievement_goal_actionContext p_context)
final ILiteral initialgoal()
returns the initial goal
static EOperator from( @Nonnull final String p_value)
returns operator from string
final Object visitAgent(final AgentParser.AgentContext p_context)
final Object visitTerm(final AgentParser.TermContext p_context)
final Object visitNumber(final AgentParser.NumberContext p_context)
ILiteral m_initialgoal
initial goal
final Object visitExecutable_action(final AgentParser.Executable_actionContext p_context)
achievement for rule-variable execution
assignment action of a multi-variable list
defines an execution element with a repair call
Object visitLogicrulePlaceHolder(final AgentParser.LogicruleContext p_context)
create a rule placeholder object
final Object visitBody(final AgentParser.BodyContext p_context)
achievement for rule-literal execution
default generic literal class for agent beliefs a literal consists of a functor, an optional list of ...
CASTVisitorAgent( @Nonnull final Set< IAction > p_actions)
ctor
assignment action of a single-variable
structure for creating evaluate variables
final Object visitExpression_logical_element(final AgentParser.Expression_logical_elementContext p_context)
static IExpression createLogicalBinaryExpression( @Nonnull final EOperator p_operator, @Nonnull final IExpression p_lefthandside, @Nonnull final Collection< IExpression > p_righthandside)
creates a logical expression concationation with single operator
static boolean logicalvalue( @Nonnull final String p_value)
converts a string token to the type
annotation without parameter
T deepcopy( @Nullable final IPath... p_prefix)
clones the object (shallow-copy)
static< N > CRawTerm< N > from(final N p_value)
factory for a raw term
class for any helper calls
final Object visitAnnotation_literal(final AgentParser.Annotation_literalContext p_context)
final Object visitExpression_numeric_relation(final AgentParser.Expression_numeric_relationContext p_context)
static ILiteral from( @Nonnull final String p_functor, @Nullable final ITerm... p_values)
factory
default variable definition
final Object visitExpression_numeric_multiplicative(final AgentParser.Expression_numeric_multiplicativeContext p_context)
Object visitAnnotation_value_literal(final AgentParser.Annotation_value_literalContext p_context)
final Object visitBody_formula(final AgentParser.Body_formulaContext p_context)
static final Map< String, Double > NUMERICCONSTANT
numeric constant values - infinity is defined manually
final Object visitUnification_constraint(final AgentParser.Unification_constraintContext p_context)
final Object visitBelief(final AgentParser.BeliefContext p_context)
final Set< ILiteral > initialbeliefs()
returns initial beliefs
final Object visitExpression_numeric_power(final AgentParser.Expression_numeric_powerContext p_context)
final Object visitAnnotation_atom(final AgentParser.Annotation_atomContext p_context)
final Object visitInitial_goal(final AgentParser.Initial_goalContext p_context)
assign operator expression
final Object visitVariable_evaluate(final AgentParser.Variable_evaluateContext p_context)
additve binary expression
final Object visitLiteral(final AgentParser.LiteralContext p_context)
interface for evaluate variables
achievement-goal action based on variables
final Object visitExpression_logical_negation(final AgentParser.Expression_logical_negationContext p_context)
final Object visitAnnotations(final AgentParser.AnnotationsContext p_context)
final Object visitPlan_belief_trigger(final AgentParser.Plan_belief_triggerContext p_context)
final Object visitLogicrule(final AgentParser.LogicruleContext p_context)
term structure for simple datatypes
final Object visitDigitsequence(final AgentParser.DigitsequenceContext p_context)
final Object visitLogicalruledefinition(final AgentParser.LogicalruledefinitionContext p_context)
final Object visitBlock_formula(final AgentParser.Block_formulaContext p_context)