DefaultSemanticMemory implements SemanticMemory { static SymbolImpl smem_parse_constant_attr(SymbolFactoryImpl syms, Lexeme lexeme) { final SymbolImpl return_val; if ((lexeme.type == LexemeType.SYM_CONSTANT)) { return_val = syms.createString(lexeme.string); } else if (lexeme.type == LexemeType.INTEGER) { return_val = syms.createInteger(lexeme.int_val); } else if (lexeme.type == LexemeType.FLOAT) { return_val = syms.createDouble(lexeme.float_val); } else { return_val = null; } return return_val; } DefaultSemanticMemory(Adaptable context);  DefaultSemanticMemory(Adaptable context, SemanticMemoryDatabase db); BasicWeightedCue getLastCue(); void initialize(); @Override void resetStatistics(); @Override SemanticMemoryStatistics getStatistics(); @Override void initializeNewContext(WorkingMemory wm, IdentifierImpl id); @Override boolean smem_enabled(); double smem_lti_calc_base(long lti, long time_now); double smem_lti_calc_base(long lti, long time_now, long n); double smem_lti_calc_base(long lti, long time_now, long n, long activations_first); static boolean smem_valid_production(Condition lhs_top, Action rhs_top); @Override long smem_lti_get_id(char name_letter, long name_number); IdentifierImpl smem_lti_soar_make(/* smem_lti_id */long lti, char name_letter, long name_number, /* goal_stack_level */int level); @Override void smem_reset_id_counters(); @Override void smem_reset(IdentifierImpl state); @Override void smem_attach(); @Override void smem_close(); @Override void smem_go(boolean store_only); @Override boolean isMirroringEnabled(); @Override Set<IdentifierImpl> smem_changed_ids(); @Override boolean smem_ignore_changes();  }
@Test public void testCanParseAStringConstant() { final SymbolFactoryImpl syms = new SymbolFactoryImpl(); final Lexeme lexeme = new Lexeme(); lexeme.type = LexemeType.SYM_CONSTANT; lexeme.string = "yumyum"; final SymbolImpl result = DefaultSemanticMemory.smem_parse_constant_attr(syms, lexeme); assertNotNull(result); assertSame(syms.findString("yumyum"), result); }
@Test public void testCanParseAnIntegerConstant() { final SymbolFactoryImpl syms = new SymbolFactoryImpl(); final Lexeme lexeme = new Lexeme(); lexeme.type = LexemeType.INTEGER; lexeme.int_val = 456; final SymbolImpl result = DefaultSemanticMemory.smem_parse_constant_attr(syms, lexeme); assertNotNull(result); assertSame(syms.findInteger(456), result); }
@Test public void testCanParseADoubleConstant() { final SymbolFactoryImpl syms = new SymbolFactoryImpl(); final Lexeme lexeme = new Lexeme(); lexeme.type = LexemeType.FLOAT; lexeme.float_val = 3.14159; final SymbolImpl result = DefaultSemanticMemory.smem_parse_constant_attr(syms, lexeme); assertNotNull(result); assertSame(syms.findDouble(3.14159), result); }