Documentation ¶
Overview ¶
Package amod implements parsing of amod files into actr.Models.
Example (ChunkDuplicateType) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [something: foo bar] [something: foo bar] } ~~ init ~~ ~~ productions ~~`)
Output: ERROR: duplicate chunk type: 'something' (line 7, col 6)
Example (ChunkInternalType) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [_internal: foo bar] } ~~ init ~~ ~~ productions ~~`)
Output: ERROR: cannot use reserved chunk type "_internal" (chunks beginning with '_' are reserved) (line 5, col 11)
Example (ChunkReservedType) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [requested: foo bar] } ~~ init ~~ ~~ productions ~~`)
Output: ERROR: cannot use reserved chunk type "requested" (line 5, col 11)
Example (GactarAllOptions) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ gactar { log_level: 'detail' trace_activations: true } ~~ init ~~ ~~ productions ~~`)
Output:
Example (GactarFieldNotANestedValue) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ gactar { log_level {} } ~~ init ~~ ~~ productions ~~`)
Output: ERROR: 'log_level' invalid type (found field; expected string) (line 5, col 21)
Example (GactarSpaceSeparator) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ gactar { log_level: 'detail' trace_activations: true } ~~ init ~~ ~~ productions ~~`)
Output:
Example (GactarTraceActivations) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ gactar { trace_activations: true } ~~ init ~~ ~~ productions ~~`)
Output:
Example (GactarTraceActivationsNonBool) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ gactar { trace_activations: 6.0 } ~~ init ~~ ~~ productions ~~`)
Output: ERROR: 'trace_activations' invalid type (found number; expected true or false) (line 5, col 29)
Example (GactarUnrecognizedField) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ gactar { foo: bar } ~~ init ~~ ~~ productions ~~`)
Output: ERROR: unrecognized option "foo" in gactar section (line 5, col 10)
Example (GactarUnrecognizedLogLevel) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ gactar { log_level: bar } ~~ init ~~ ~~ productions ~~`)
Output: ERROR: 'log_level' invalid type (found id; expected string) (line 5, col 21)
Example (GactarUnrecognizedNestedValue) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ gactar { foo {} } ~~ init ~~ ~~ productions ~~`)
Output: ERROR: unrecognized option "foo" in gactar section (line 5, col 10)
Example (ImaginalFieldRange) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ modules { imaginal { delay: -0.5 } } ~~ init ~~ ~~ productions ~~`)
Output: ERROR: imaginal "delay" is out of range (minimum 0) (line 6, col 20)
Example (ImaginalFieldType) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ modules { imaginal { delay: "gack" } } ~~ init ~~ ~~ productions ~~`)
Output: ERROR: imaginal "delay" invalid type (found string; expected number) (line 6, col 20)
Example (ImaginalFieldUnrecognized) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ modules { imaginal { foo: bar } } ~~ init ~~ ~~ productions ~~`)
Output: ERROR: unrecognized option "foo" in imaginal config (line 6, col 13)
Example (ImaginalFields) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ modules { imaginal { delay: 0.2 } memory { latency_factor: 0.5 } } ~~ init ~~ ~~ productions ~~`)
Output:
Example (Initializer1) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [remember: person] [author: person object] } ~~ init ~~ memory { [remember: me] [author: 'me' 'software'] } ~~ productions ~~`)
Output:
Example (Initializer2) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [author: person object year] } ~~ init ~~ goal [author: 'Fred' 'Book' '1972'] ~~ productions ~~`)
Output:
Example (Initializer3) ¶
// memory with one init is allowed generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [author: person object year] } ~~ init ~~ memory [author: 'Jane' 'Book' '1982'] ~~ productions ~~`)
Output:
Example (Initializer4) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [remember: person] [author: person object] } ~~ init ~~ memory { retrieval { [remember: 'me'] [author: 'me' 'software'] } } ~~ productions ~~`)
Output:
Example (Initializer5) ¶
// memory with named chunks generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [author: person object year] } ~~ init ~~ memory { bar [author: 'Fred' 'Book' '1972'] foo [author: 'Jane' 'Book' '1982'] [author: 'Xe' 'Software' '2001'] } ~~ productions ~~`)
Output:
Example (Initializer6) ¶
// memory with one init and named chunk generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [author: person object year] } ~~ init ~~ memory foo [author: 'Jane' 'Book' '1982'] ~~ productions ~~`)
Output:
Example (InitializerDuplicateNames) ¶
// memory with named chunks generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [author: person object year] } ~~ init ~~ memory { foo [author: 'Fred' 'Book' '1972'] foo [author: 'Jane' 'Book' '1982'] [author: 'Xe' 'Software' '2001'] } ~~ productions ~~`)
Output: ERROR: duplicate chunk name "foo" found in initialization (line 9, col 2)
Example (InitializerInvalidChunk1) ¶
// Check memory with invalid chunk generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ ~~ init ~~ memory { [author: 'me' 'software'] } ~~ productions ~~`)
Output: ERROR: could not find chunk named 'author' (line 6, col 11)
Example (InitializerInvalidChunk2) ¶
// Check buffer with invalid chunk generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ ~~ init ~~ goal [author: 'Fred' 'Book' '1972'] ~~ productions ~~`)
Output: ERROR: could not find chunk named 'author' (line 6, col 7)
Example (InitializerInvalidSlots) ¶
// Check invalid number of slots in init generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [author: person object year] } ~~ init ~~ memory { [author: 'me' 'software'] } ~~ productions ~~`)
Output: ERROR: invalid chunk - 'author' expects 3 slots (line 7, col 10)
Example (InitializerMultipleBuffers) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ modules { extra_buffers { buffer1 {} buffer2 {} } } chunks { [author: person object year] } ~~ init ~~ extra_buffers { buffer1 { [author: 'Fred' 'Book' '1972'] } buffer2 { [author: 'Jane' 'Book' '1984'] } } ~~ productions ~~`)
Output:
Example (InitializerMultipleInits) ¶
// Check buffer with multiple inits generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [author: person object year] } ~~ init ~~ goal { [author: 'Fred' 'Book' '1972'] [author: 'Jane' 'Book' '1982'] } ~~ productions ~~`)
Output: ERROR: module "goal" should only have one pattern in initialization of buffer "goal" (line 7, col 8)
Example (InitializerNoBuffers) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ modules { extra_buffers{} } chunks { [author: person object year] } ~~ init ~~ extra_buffers { [author: 'Jane' 'Book' '1984'] [author: 'Xe' 'Book' '1999'] } ~~ productions ~~`)
Output: ERROR: module 'extra_buffers' does not have any buffers (line 8, col 1)
Example (InitializerPartialSimilarities) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ modules { memory { mismatch_penalty: 1.0 } } chunks { [group: id parent position] } ~~ init ~~ memory { [group: group1 list first] [group: group2 list second] [group: group3 list third] } similar { ( first second -0.5 ) ( second third -0.5 ) } ~~ productions ~~`)
Output:
Example (InitializerUnknownBuffer) ¶
// Check unknown buffer generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [author: person object year] } ~~ init ~~ something [author: 'Fred' 'Book' '1972'] ~~ productions ~~`)
Output: ERROR: module 'something' not found in initialization (line 7, col 1)
Example (KeywordInDifferentSection) ¶
Tests that we can use a keyword from one section as an id in another
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [name: first last] } ~~ init ~~ ~~ productions ~~`)
Output:
Example (MemoryDecayOutOfRange) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ modules { memory { decay: -0.5 } } ~~ init ~~ ~~ productions ~~`)
Output: ERROR: memory "decay" is out of range (0-1) (line 6, col 18)
Example (MemoryDecayOutOfRange2) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ modules { memory { decay: 1.5 } } ~~ init ~~ ~~ productions ~~`)
Output: ERROR: memory "decay" is out of range (0-1) (line 6, col 18)
Example (MemoryFieldUnrecognized) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ modules { memory { foo: bar } } ~~ init ~~ ~~ productions ~~`)
Output: ERROR: unrecognized option "foo" in memory config (line 6, col 11)
Example (ModelAuthors) ¶
generateToStdout(` ~~ model~~ name: Test authors { 'Andy Maloney <andy@example.com>' // did all the work 'Hiro Protagonist <hiro@example.com>' // fixed some things } ~~ config ~~ ~~ init ~~ ~~ productions ~~`)
Output:
Example (ModelExampleBadChunk) ¶
generateToStdout(` ~~ model~~ name: Test examples { [foo: 'bar'] } ~~ config ~~ ~~ init ~~ ~~ productions ~~`)
Output: ERROR: could not find chunk named 'foo' (line 4, col 13)
Example (ModelExamples) ¶
generateToStdout(` ~~ model~~ name: Test examples { [foo: 'bar'] } ~~ config ~~ chunks { [foo: thing] } ~~ init ~~ ~~ productions ~~`)
Output:
Example (Modules) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ modules { imaginal { delay: 0.2 } } ~~ init ~~ ~~ productions ~~`)
Output:
Example (ModulesAll) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ modules { imaginal { delay: 0.2 imaginal { spreading_activation: 0.5 } } memory { latency_factor: 0.5 latency_exponent: 0.75 retrieval_threshold: 0.1 finst_size: 5 finst_time: 2.5 decay: 0.6 max_spread_strength: 0.9 instantaneous_noise: 0.5 mismatch_penalty: 1.0 retrieval { spreading_activation: 0.5 } } procedural { default_action_time: 0.06 } goal{ goal { spreading_activation: 0.5 } } } ~~ init ~~ ~~ productions ~~`)
Output:
Example (ModulesExtraBuffers) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ modules { extra_buffers { buffer1 {} buffer2 {} } } ~~ init ~~ ~~ productions ~~`)
Output:
Example (ModulesExtraBuffersDuplicate) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ modules { extra_buffers { buffer1 {} buffer1 {} } } ~~ init ~~ ~~ productions ~~`)
Output: ERROR: duplicate option "buffer1" (line 8, col 3)
Example (ModulesInitBuffer) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ modules { memory { max_spread_strength: 0.9 retrieval { spreading_activation: 0.5 } } } ~~ init ~~ ~~ productions ~~`)
Output:
Example (ModulesInitBufferDuplicate) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ modules { memory { max_spread_strength: 0.9 retrieval { spreading_activation: 0.5 spreading_activation: 0.5 } } } ~~ init ~~ ~~ productions ~~`)
Output: ERROR: duplicate option "spreading_activation" (line 10, col 4)
Example (ModulesInitBufferNoMaxSpread) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ modules { imaginal { imaginal { spreading_activation: 0.5 } } } ~~ init ~~ ~~ productions ~~`)
Output: ERROR: spreading_activation set on buffer "imaginal", but max_spread_strength not set on memory module (line 5, col 1)
Example (ModulesUnrecognizedModule) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ modules { foo { delay: 0.2 } } ~~ init ~~ ~~ productions ~~`)
Output: ERROR: unrecognized module in config: 'foo' (line 6, col 2)
Example (ModulesUnrecognizedModuleDuplicateOption) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ modules { imaginal { imaginal {} imaginal {} } } ~~ init ~~ ~~ productions ~~`)
Output: ERROR: duplicate option "imaginal" (line 8, col 3)
Example (ModulesUnrecognizedModuleOption) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ modules { goal { foo: 0.2 } } ~~ init ~~ ~~ productions ~~`)
Output: ERROR: unrecognized option "foo" in goal config (line 6, col 9)
Example (ProceduralFieldUnrecognized) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ modules { procedural { foo: bar } } ~~ init ~~ ~~ productions ~~`)
Output: ERROR: unrecognized option "foo" in procedural config (line 6, col 15)
Example (Production) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: ?blat] } do { print ?blat stop } }`)
Output:
Example (ProductionChunkNotFound) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ ~~ init ~~ ~~ productions ~~ start { match { goal [foo: error] } do { print 42 } }`)
Output: ERROR: could not find chunk named 'foo' (line 8, col 16)
Example (ProductionClearStatement) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: 'blat'] } do { clear goal } }`)
Output:
Example (ProductionClearStatementInvalidBuffer) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: 'blat'] } do { clear some_buffer } }`)
Output: ERROR: buffer 'some_buffer' not found in production 'start' (line 10, col 7)
Example (ProductionInvalidMemory) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ ~~ init ~~ ~~ productions ~~ start { match { another_goal [add: ?thing1 ?thing2] } do { print 'foo' } }`)
Output: ERROR: buffer 'another_goal' not found in production 'start' (line 8, col 10)
Example (ProductionMatchBufferAny) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ ~~ init ~~ ~~ productions ~~ start { match { retrieval [any] } do { print 42 } }`)
Output:
Example (ProductionMatchBufferState) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ ~~ init ~~ ~~ productions ~~ start { match { buffer_state retrieval empty } do { print 42 } }`)
Output:
Example (ProductionMatchBufferStateDuplicate) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ ~~ init ~~ ~~ productions ~~ start { match { buffer_state retrieval full buffer_state retrieval empty } do { print 42 } }`)
Output: ERROR: duplicate buffer state check for 'retrieval' in production 'start' (line 10, col 3)
Example (ProductionMatchBufferStateInvalidBuffer) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ ~~ init ~~ ~~ productions ~~ start { match { buffer_state foo empty } do { print 42 } }`)
Output: ERROR: buffer 'foo' not found in production 'start' (line 8, col 10)
Example (ProductionMatchBufferStateInvalidNumber) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ ~~ init ~~ ~~ productions ~~ start { match { buffer_state goal 42 } do { print 42 } }`)
Output: ERROR: unexpected token "42" (expected <ident>) (line 8, col 28)
Example (ProductionMatchBufferStateInvalidStatus) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ ~~ init ~~ ~~ productions ~~ start { match { buffer_state retrieval foo } do { print 42 } }`)
Output: ERROR: invalid state check 'foo' for buffer 'retrieval' in production 'start' (should be one of: empty, full) (line 8, col 10)
Example (ProductionMatchBufferStateInvalidString) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ ~~ init ~~ ~~ productions ~~ start { match { buffer_state goal 'empty' } do { print 42 } }`)
Output: ERROR: unexpected token "empty" (expected <ident>) (line 8, col 28)
Example (ProductionMatchModuleState) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ ~~ init ~~ ~~ productions ~~ start { match { module_state memory error } do { print 42 } }`)
Output:
Example (ProductionMatchModuleStateDuplicate) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ ~~ init ~~ ~~ productions ~~ start { match { module_state memory error module_state memory busy } do { print 42 } }`)
Output: ERROR: duplicate module state check for 'memory' in production 'start' (line 10, col 3)
Example (ProductionMatchModuleStateInvalidModule) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ ~~ init ~~ ~~ productions ~~ start { match { module_state foo error } do { print 42 } }`)
Output: ERROR: module 'foo' not found in production 'start' (line 8, col 10)
Example (ProductionMatchModuleStateInvalidState1) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ ~~ init ~~ ~~ productions ~~ start { match { module_state memory 'foo' } do { print 42 } }`)
Output: ERROR: unexpected token "foo" (expected <ident>) (line 8, col 30)
Example (ProductionMatchModuleStateInvalidState2) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ ~~ init ~~ ~~ productions ~~ start { match { module_state memory bar } do { print 42 } }`)
Output: ERROR: invalid module state check 'bar' for module 'memory' in production 'start' (should be one of: busy, error, free) (line 8, col 10)
Example (ProductionMultipleStatement) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing1 thing2] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: ?next ?other] } do { recall [foo: ?next *] set goal to [foo: ?other 42] } }`)
Output:
Example (ProductionNoDo) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: ?blat] } }`)
Output: ERROR: unexpected token "}" (expected Do "}") (line 10, col 1)
Example (ProductionNotWildcard) ¶
// Odd error message. // See: https://github.com/asmaloney/gactar/issues/124 generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing1 thing2] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: ?blat !*] } do { print ?blat } }`)
Output: ERROR: unexpected token "!" (expected "]") (line 9, col 27)
Example (ProductionPrintStatement1) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing1 thing2] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: * ?other] } do { print 42, ?other, 'blat' } }`)
Output:
Example (ProductionPrintStatement2) ¶
// Test print with vars from two different buffers generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing1 thing2] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: * ?other] retrieval [foo: * ?other1] } do { print 42, ?other, ?other1, 'blat' } }`)
Output:
Example (ProductionPrintStatement3) ¶
// print without args // https://github.com/asmaloney/gactar/issues/7 generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ ~~ init ~~ ~~ productions ~~ start { match { buffer_state goal empty } do { print } }`)
Output:
Example (ProductionPrintStatementBuffer) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ ~~ init ~~ ~~ productions ~~ start { match { buffer_state retrieval empty } do { print goal } }`)
Output:
Example (ProductionPrintStatementBufferSlot) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing1 thing2] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: * *] } do { print goal.thing1 } }`)
Output:
Example (ProductionPrintStatementInvalidBuffer) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ ~~ init ~~ ~~ productions ~~ start { match { buffer_state retrieval empty } do { print fooID } }`)
Output: ERROR: buffer "fooID" not found in model (line 9, col 13)
Example (ProductionPrintStatementInvalidBufferSlot) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing1 thing2] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: * *] } do { print goal.blat } }`)
Output: ERROR: slot 'blat' does not exist in chunk type 'foo' for match buffer 'goal' in production 'start' (line 10, col 18)
Example (ProductionPrintStatementInvalidNil) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ ~~ init ~~ ~~ productions ~~ start { match { buffer_state goal empty } do { print nil } }`)
Output: ERROR: unexpected token "nil" (expected "}") (line 9, col 13)
Example (ProductionPrintStatementInvalidVar) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ ~~ init ~~ ~~ productions ~~ start { match { buffer_state retrieval empty } do { print ?fooVar } }`)
Output: ERROR: print statement variable '?fooVar' not found in matches for production 'start' (line 9, col 13)
Example (ProductionPrintStatementWildcard) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ ~~ init ~~ ~~ productions ~~ start { match { buffer_state goal empty } do { print * } }`)
Output: ERROR: unexpected token "*" (expected "}") (line 9, col 13)
Example (ProductionRecallStatement) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing1 thing2] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: ?next *] } do { recall [foo: ?next *] } }`)
Output:
Example (ProductionRecallStatementInvalidPattern) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing1 thing2] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: ?next *] } do { recall [foo: ?next * 'bar'] } }`)
Output: ERROR: invalid chunk - 'foo' expects 2 slots (line 10, col 14)
Example (ProductionRecallStatementMultiple) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing1 thing2] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: ?next *] } do { recall [foo: ?next *] recall [foo: * ?next] } }`)
Output: ERROR: only one recall statement per production is allowed in production 'start' (line 12, col 3)
Example (ProductionRecallStatementVarNotFound) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing] [bar: other thing] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: 'blat'] } do { recall [bar: ?next *] } }`)
Output: ERROR: recall statement variable '?next' not found in matches for production 'start' (line 10, col 20)
Example (ProductionRecallStatementWithID) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing1 thing2] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: ?next *] } do { recall [foo: ?next *] with ( recently_retrieved t ) } }`)
Output:
Example (ProductionRecallStatementWithIncorrectNumArgs) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing1 thing2] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: ?next *] } do { recall [foo: ?next *] with ( recently_retrieved nil nil ) } }`)
Output: ERROR: unexpected token "nil" (expected ")") (line 10, col 59)
Example (ProductionRecallStatementWithInvalidParam) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing1 thing2] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: ?next *] } do { recall [foo: ?next *] with ( foo_param 42 ) } }`)
Output: ERROR: recall 'with': unrecognized option "foo_param". (line 10, col 34)
Example (ProductionRecallStatementWithMultipleWith) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing1 thing2] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: ?next *] } do { recall [foo: ?next *] with ( recently_retrieved reset ) and ( recently_retrieved t ) } }`)
Output:
Example (ProductionRecallStatementWithNIL) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing1 thing2] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: ?next *] } do { recall [foo: ?next *] with ( recently_retrieved nil ) } }`)
Output:
Example (ProductionRecallStatementWithString) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing1 thing2] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: ?next *] } do { recall [foo: ?next *] with ( recently_retrieved "bar" ) } }`)
Output: ERROR: recall 'with': invalid value "bar" for option "recently_retrieved" (expected one of: t, nil, reset). (line 10, col 34)
Example (ProductionRecallStatementWithVar) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing1 thing2] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: ?next *] } do { recall [foo: ?next *] with ( recently_retrieved ?bar ) } }`)
Output: ERROR: recall 'with': parameter 'recently_retrieved'. Unexpected variable (line 10, col 34)
Example (ProductionRecallStatementWithWith) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing1 thing2] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: ?next *] } do { recall [foo: ?next *] with ( recently_retrieved reset ) } }`)
Output:
Example (ProductionSetStatementAssignNonPattern) ¶
// Check setting buffer to non-pattern // https://github.com/asmaloney/gactar/issues/28 generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: 'blat'] } do { set goal to 6 } }`)
Output: ERROR: buffer 'goal' must be set to a pattern in production 'start' (line 10, col 19)
Example (ProductionSetStatementAssignPattern) ¶
// Check assignment of pattern to slot // https://github.com/asmaloney/gactar/issues/17 generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: 'blat'] } do { set goal.thing to [foo: 'ding'] } }`)
Output: ERROR: cannot set a slot ('goal.thing') to a pattern in production 'start' (line 10, col 11)
Example (ProductionSetStatementID) ¶
// Check setting to ID generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: 'thing'] } do { set goal.thing to thing2 } }`)
Output:
Example (ProductionSetStatementInvalidSlot) ¶
// Check setting to buffer not used in the match generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: 'blat'] } do { set goal.bar to 'blat' } }`)
Output: ERROR: slot 'bar' does not exist in chunk type 'foo' for match buffer 'goal' in production 'start' (line 10, col 16)
Example (ProductionSetStatementNil) ¶
// Check setting to nil generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ modules { imaginal { delay: 0.2 } } chunks { [foo: thing] [ack: knowledge] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: 'blat'] imaginal [ack: 'bar'] } do { set goal.thing to nil set imaginal.knowledge to nil } }`)
Output:
Example (ProductionSetStatementNonBuffer) ¶
// Check setting to non-existent buffer in set statement generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: 'blat'] } do { set foo.bar to 'blat' } }`)
Output: ERROR: buffer "foo" not found in model (line 10, col 11)
Example (ProductionSetStatementNonBuffer2) ¶
// Check setting to buffer not used in the match generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ modules { imaginal { delay: 0.2 } } chunks { [foo: thing] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: 'blat'] } do { set imaginal.bar to 'blat' } }`)
Output: ERROR: match buffer 'imaginal' not found in production 'start' (line 11, col 11)
Example (ProductionSetStatementNonVar1) ¶
// Check setting to non-existent var generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: 'blat'] } do { set goal.thing to ?ding } }`)
Output: ERROR: set statement variable '?ding' not found in matches for production 'start' (line 10, col 25)
Example (ProductionSetStatementNonVar2) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: 'blat'] } do { set goal to [foo: ?ding] } }`)
Output: ERROR: set statement variable '?ding' not found in matches for production 'start' (line 10, col 25)
Example (ProductionSetStatementPattern) ¶
// Check setting to pattern generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing] } ~~ init ~~ ~~ productions ~~ start { description: "This is a description" match { goal [foo: 'blat'] } do { set goal to [foo: 'ding'] } }`)
Output:
Example (ProductionSetStatementString) ¶
// Check setting to ID generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: 'thing'] } do { set goal.thing to 'thing string' } }`)
Output:
Example (ProductionSetStatementVar) ¶
// Check setting to var generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: ?blat] } do { set goal.thing to ?blat } }`)
Output:
Example (ProductionUnusedVar1) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: ?blat] } do { set goal to [foo: ding] } }`)
Output: ERROR: variable ?blat is not used - should be simplified to '*' (line 9, col 21)
Example (ProductionUnusedVar2) ¶
// Check that using a var twice in a buffer match does not get // marked as unused. generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing1 thing2] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: ?blat ?blat] } do { set goal to [foo: ding] } }`)
Output:
Example (ProductionWhenClause) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: ?blat] when ( ?blat == 'foo' ) } do { print ?blat stop } }`)
Output:
Example (ProductionWhenClauseCompareID) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: ?blat] when ( ?blat == bar ) } do { print ?blat stop } }`)
Output: ERROR: unexpected token "bar" (expected WhenArg ")") (line 10, col 37)
Example (ProductionWhenClauseCompareNil) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: ?blat] when ( ?blat == nil ) } do { print ?blat stop } }`)
Output:
Example (ProductionWhenClauseComparisonToSelf) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: ?blat] when ( ?blat == ?blat ) } do { print ?blat stop } }`)
Output: ERROR: cannot compare a variable to itself '?blat' (line 10, col 37)
Example (ProductionWhenClauseInvalidVarLHS) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: ?blat] when ( ?ding == 42 ) } do { print ?blat stop } }`)
Output: ERROR: unknown variable ?ding in where clause (line 10, col 28)
Example (ProductionWhenClauseInvalidVarRHS) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: ?blat] when ( ?blat != ?ding ) } do { print ?blat stop } }`)
Output: ERROR: unknown variable ?ding in where clause (line 10, col 37)
Example (ProductionWhenClauseNegatedAndConstrained) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: !?blat] when ( ?blat == 'foo' ) } do { print ?blat stop } }`)
Output: ERROR: cannot further constrain a negated variable '?blat' (line 11, col 11)
Example (ProductionWildcard) ¶
generateToStdout(` ~~ model ~~ name: Test ~~ config ~~ chunks { [foo: thing1 thing2] } ~~ init ~~ ~~ productions ~~ start { match { goal [foo: ?blat *] } do { print ?blat } }`)
Output:
Index ¶
- Constants
- Variables
- func GenerateModel(buffer string) (model *actr.Model, iLog *issues.Log, err error)
- func GenerateModelFromFile(fileName string) (model *actr.Model, iLog *issues.Log, err error)
- func OutputEBNF()
- func ParseChunk(model *actr.Model, chunk string) (*actr.Pattern, error)
- func SetDebug(options []string)
- type ErrParseChunk
- type LexError
Examples ¶
- Package (ChunkDuplicateType)
- Package (ChunkInternalType)
- Package (ChunkReservedType)
- Package (GactarAllOptions)
- Package (GactarFieldNotANestedValue)
- Package (GactarSpaceSeparator)
- Package (GactarTraceActivations)
- Package (GactarTraceActivationsNonBool)
- Package (GactarUnrecognizedField)
- Package (GactarUnrecognizedLogLevel)
- Package (GactarUnrecognizedNestedValue)
- Package (ImaginalFieldRange)
- Package (ImaginalFieldType)
- Package (ImaginalFieldUnrecognized)
- Package (ImaginalFields)
- Package (Initializer1)
- Package (Initializer2)
- Package (Initializer3)
- Package (Initializer4)
- Package (Initializer5)
- Package (Initializer6)
- Package (InitializerDuplicateNames)
- Package (InitializerInvalidChunk1)
- Package (InitializerInvalidChunk2)
- Package (InitializerInvalidSlots)
- Package (InitializerMultipleBuffers)
- Package (InitializerMultipleInits)
- Package (InitializerNoBuffers)
- Package (InitializerPartialSimilarities)
- Package (InitializerUnknownBuffer)
- Package (KeywordInDifferentSection)
- Package (MemoryDecayOutOfRange)
- Package (MemoryDecayOutOfRange2)
- Package (MemoryFieldUnrecognized)
- Package (ModelAuthors)
- Package (ModelExampleBadChunk)
- Package (ModelExamples)
- Package (Modules)
- Package (ModulesAll)
- Package (ModulesExtraBuffers)
- Package (ModulesExtraBuffersDuplicate)
- Package (ModulesInitBuffer)
- Package (ModulesInitBufferDuplicate)
- Package (ModulesInitBufferNoMaxSpread)
- Package (ModulesUnrecognizedModule)
- Package (ModulesUnrecognizedModuleDuplicateOption)
- Package (ModulesUnrecognizedModuleOption)
- Package (ProceduralFieldUnrecognized)
- Package (Production)
- Package (ProductionChunkNotFound)
- Package (ProductionClearStatement)
- Package (ProductionClearStatementInvalidBuffer)
- Package (ProductionInvalidMemory)
- Package (ProductionMatchBufferAny)
- Package (ProductionMatchBufferState)
- Package (ProductionMatchBufferStateDuplicate)
- Package (ProductionMatchBufferStateInvalidBuffer)
- Package (ProductionMatchBufferStateInvalidNumber)
- Package (ProductionMatchBufferStateInvalidStatus)
- Package (ProductionMatchBufferStateInvalidString)
- Package (ProductionMatchModuleState)
- Package (ProductionMatchModuleStateDuplicate)
- Package (ProductionMatchModuleStateInvalidModule)
- Package (ProductionMatchModuleStateInvalidState1)
- Package (ProductionMatchModuleStateInvalidState2)
- Package (ProductionMultipleStatement)
- Package (ProductionNoDo)
- Package (ProductionNotWildcard)
- Package (ProductionPrintStatement1)
- Package (ProductionPrintStatement2)
- Package (ProductionPrintStatement3)
- Package (ProductionPrintStatementBuffer)
- Package (ProductionPrintStatementBufferSlot)
- Package (ProductionPrintStatementInvalidBuffer)
- Package (ProductionPrintStatementInvalidBufferSlot)
- Package (ProductionPrintStatementInvalidNil)
- Package (ProductionPrintStatementInvalidVar)
- Package (ProductionPrintStatementWildcard)
- Package (ProductionRecallStatement)
- Package (ProductionRecallStatementInvalidPattern)
- Package (ProductionRecallStatementMultiple)
- Package (ProductionRecallStatementVarNotFound)
- Package (ProductionRecallStatementWithID)
- Package (ProductionRecallStatementWithIncorrectNumArgs)
- Package (ProductionRecallStatementWithInvalidParam)
- Package (ProductionRecallStatementWithMultipleWith)
- Package (ProductionRecallStatementWithNIL)
- Package (ProductionRecallStatementWithString)
- Package (ProductionRecallStatementWithVar)
- Package (ProductionRecallStatementWithWith)
- Package (ProductionSetStatementAssignNonPattern)
- Package (ProductionSetStatementAssignPattern)
- Package (ProductionSetStatementID)
- Package (ProductionSetStatementInvalidSlot)
- Package (ProductionSetStatementNil)
- Package (ProductionSetStatementNonBuffer)
- Package (ProductionSetStatementNonBuffer2)
- Package (ProductionSetStatementNonVar1)
- Package (ProductionSetStatementNonVar2)
- Package (ProductionSetStatementPattern)
- Package (ProductionSetStatementString)
- Package (ProductionSetStatementVar)
- Package (ProductionUnusedVar1)
- Package (ProductionUnusedVar2)
- Package (ProductionWhenClause)
- Package (ProductionWhenClauseCompareID)
- Package (ProductionWhenClauseCompareNil)
- Package (ProductionWhenClauseComparisonToSelf)
- Package (ProductionWhenClauseInvalidVarLHS)
- Package (ProductionWhenClauseInvalidVarRHS)
- Package (ProductionWhenClauseNegatedAndConstrained)
- Package (ProductionWildcard)
Constants ¶
View Source
const (
LexemeEOF lexemeType
)
Variables ¶
View Source
var ( ErrParse = errors.New("failed to parse amod file") ErrCompile = errors.New("failed to compile amod file") ErrStatementNotHandled = errors.New("statement type not handled") )
View Source
var LexerDefinition lexer.Definition = lexer_def{}
LexerDefinition provides the interface for the participle parser
Functions ¶
func GenerateModel ¶
GenerateModel generates a model from the text in the buffer.
func GenerateModelFromFile ¶
GenerateModelFromFile generates a model from the file 'fileName'.
func OutputEBNF ¶
func OutputEBNF()
OutputEBNF outputs the extended Backus–Naur form (EBNF) of the amod grammar to stdout. See: https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form
func ParseChunk ¶
ParseChunk is used to parse goals when given as input from a user.
Types ¶
type ErrParseChunk ¶ added in v0.9.0
type ErrParseChunk struct {
Message string
}
func (ErrParseChunk) Error ¶ added in v0.9.0
func (e ErrParseChunk) Error() string
Click to show internal directories.
Click to hide internal directories.