NAME

Soar::Production::Parser - PARSES SOAR PRODUCTIONS

VERSION

version 1.122800

SYNOPSIS

use Soar::Production::Parser;
use Data::Dumper;
my $parser = Soar::Production::Parser->new;
my @trees=$parser->parse_file("foo.soar");
print Dumper(\@tree);

NAME

Soar::Production::Parser - Perl extension for parsing angst grammar files

METHODS

new

Creates a new parser.

parse_text

Argument: the text of a single Soar production. Returns: a parse tree for the given production.

get_parses

Argument: Reference to array containing text for individual productions. Return: Reference to an array containing parse trees for each of the productions in the input array reference.

no_comment Argument: Text which contains Soar productions or commands Return: Same text, but with all comments removed. Comments are indicated with a # (pound), optionally preceded by a ; (semicolon) and whitespace.

productions

This method extracts productions from a given text. It returns a reference to an array containing either the text of each of the productions, or a parse tree for each of them. Note that all comments are removed as a preprocessing step to detecting and extracting productions. It takes a set of named arguments: 'file'- the name of a file to read. 'text'- the text to split. 'parse'- set to true if the return value should be an array of parse trees for the extracted productions; otherwise an array containing the production text will be returned. For example, if you would like to extract all of the productions from a file and print their parse trees, you could do this:

    use Soar::Production::Parser;
	use Data::Dumper;
	
	my $file = shift;
	my $parser = Soar::Production::Parser->new();
	my $parses = $parser->productions(
		file => $file,
		parse => 1
	);
	
	for my $prod(@$productions){
		print Dumper($prod);
	}

AUTHOR

Nathan Glenn <garfieldnate@gmail.com>

COPYRIGHT AND LICENSE

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.