Soar::Production::Parser::PRDGrammar - Parse::RecDescent grammar for Soar productions
version 0.03
use Soar::Production::Parser::PRDGrammar; use Parse::RecDescent; my $some_text = 'Soar productions here'; my $parser = Parse::RecDescent->new($Soar::Production::Parser::PRDGrammar::GRAMMAR); $parser->parse($some_text);
This module holds one global string: a Parse::RecDescent grammar for parsing Soar productions. It is not really intended for public consumption, but for use by modules Soar::Production distribution.
Parse::RecDescent
Soar::Production::Parser::PRDGrammar - Parse::RecDescent grammar for parsing Soar productions.
The following is a description of a grammar describing Soar productions, from the Soar manual. Note also that a /(;\s*)?\#/ (pound sign optionally preceded by semi-colon and white space) indicates an end-of-line comment. Soar does not have multi-line comments.
A grammar for Soar productions is:
<soar-production> ::= sp "{" <production-name> [<documentation>] [<flags>] <condition-side> --> <action-side> "}" <documentation> ::= """ [<string>] """ <flags> ::= ":" (o-support | i-support | chunk | default)
I have modified the grammar below from the original to account for the fact that an instance of <state-imp-cond> is not required to start the LHS, and may actually occur anywhere inside of it.
Below is a grammar for the condition sides of productions: <condition-side> ::= <cond>+ <cond> ::= <positive_cond> | "-" <positive_cond> <positive_cond> ::= <state-imp-cond> | <conds_for_one_id> | "{" <cond>+ "}" <state-imp-cond> ::= "(" (state | impasse) [<id_test>] <attr_value_tests>+ ")" <conds_for_one_id> ::= "(" [(state|impasse)] <id_test> <attr_value_tests>+ ")" <id_test> ::= <test> <attr_value_tests> ::= ["-"] "^" <attr_test> ("." <attr_test>)* <value_test>* <attr_test> ::= <test> <value_test> ::= <test> ["+"] | <conds_for_one_id> ["+"] <test> ::= <conjunctive_test> | <simple_test> <conjunctive_test> ::= "{" <simple_test>+ "}" <simple_test> ::= <disjunction_test> | <relational_test> <disjunction_test> ::= "<<" <constant>+ ">>" <relational_test> ::= [<relation>] <single_test> <relation> ::= "<>" | "<" | ">" | "<=" | ">=" | "=" | "<=>" <single_test> ::= <variable> | <constant> <variable> ::= "<" <sym_constant> ">" <constant> ::= <sym_constant> | <int_constant> | <float_constant>
In an <id_test>, only a <variable> may be used in a <single_test>.
Below is a grammar for the action sides of productions:
<rhs> ::= <rhs_action>* <rhs_action> ::= "(" <variable> <attr_value_make>+ ")" | <func_call> <func_call> ::= "(" <func_name> <rhs_value>* ")" <func_name> ::= <sym_constant> | "+" | "-" | "*" | "/" <rhs_value> ::= <constant> | <func_call> | <variable> <attr_value_make> ::= "^" <variable_or_sym_constant> ("." <variable_or_sym_constant>)* <value_make>+ <variable_or_sym_constant> ::= <variable> | <sym_constant> <value_make> ::= <rhs_value> <preference_specifier>* <preference-specifier> ::= <unary-preference> [","] | <unary-or-binary-preference> [","] | <unary-or-binary-preference> <rhs_value> [","] <unary-pref> ::= "+" | "-" | "!" | "~" | "@" <unary-or-binary-pref> ::= ">" | "=" | "<" | "&"
This grammar does not check for the semantic correctness of a production. For example, the following parses just fine:
sp {foo (state) --> (<s> ^foo <a>) } Whereas the real Soar parser gives us an error, saying that <lt>s<gt> is not connected to the LHS in any way.
In Soar, numbers cannot be used to name a working memory element unless they are quoted; this is a known bug. This grammar does not implement that specific bug/feature, and thus the following is accepted, even though Soar would reject it:
sp {bad-numbers (state <s> ^string.2.string) --> }
The documentation for Soar is located at https://code.google.com/p/soar/
Nathan Glenn <garfieldnate@gmail.com>
This software is copyright (c) 2012 by Nathan Glenn.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Soar::Production, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Soar::Production
CPAN shell
perl -MCPAN -e shell install Soar::Production
For more information on module installation, please visit the detailed CPAN module installation guide.