I have made good progress but have hit another sticking point. A smallest
test program is here

https://gist.github.com/jalvo2014/9631309

The sample fragment I am parsing in the test program is

my $ipdt = "*IF *VALUE i5OS_IOA_Cache_Battery.State *EQ Error";

The G1 rule is here [there is an earlier rule that strips out the *IF]

<basic_condition>     ::= '*VALUE' <attribute> <comparison>
<compare_string>  action => do_basic

Attribute has rules

<attribute>              ::= id '.' id | id

<alpha>              ~ [A-Za-z%*]

<alphanump>              ~ [A-Za-z0-9_%/]*

<id>                ~ <alpha><alphanump>

Which should pick out the two parts -sort of table and column name

next is

<comparison>          ::= '*EQ' | '*GE' | '*GT' | '*LE' | '*LT' | '*NE'

The last section - compare_string

<compare_string> ::=   <literal_word>
<literal_word> ~ [\S]+

I wanted to get that as a text blob. The problem I get is that the
attribute section is being managed by <literal_word> and the <attribute>
logic is being ignored, The end of the tracing looks like this

Lexer "L0" rejected lexeme L1c12-39: literal_word;
value="i5OS_IOA_Cache_Battery
.State"
Error in SLIF parse: No lexemes accepted at line 1, column 12
  Rejected lexeme #0: Lexer "L0"; literal_word;
value="i5OS_IOA_Cache_Battery.St
ate"; length = 28
* String before error: *IF *VALUE\s
* The error was at line 1, column 12, and at character 0x0069 'i', ...
* here: i5OS_IOA_Cache_Battery.State *EQ Error

I figure there has to be some ordering about which rules to apply but have
not found them after several hours.

John Alvord






On Sun, Mar 16, 2014 at 12:14 PM, John Alvord <[email protected]>wrote:

> Thanks Jeffrey - worked just fine. Later I found some of the values were
> array and some not.
>
> Project back on track!!
>
> John Alvord
>
>
> On Sat, Mar 15, 2014 at 5:17 PM, Jeffrey Kegler <
> [email protected]> wrote:
>
>>  I forked this and made a couple of 
>> changes<https://gist.github.com/jeffreykegler/9575923/revisions>that should 
>> get you going on the semantics.  I could not figure out how to
>> send a pull request.  Is that possible for gists?
>>
>> By default rules, rules return 'undef', which explains what you were
>> seeing.
>>
>> To get started on a script, it is best to change that default, as I did
>> in the gist, adding this line:
>>
>>  :default ::= action => ::array
>>
>>
>> It should be the default, but is not for reasons of backward
>> compatibility.
>>
>> Hope this helps, jeffrey
>>
>>
>>  On 03/15/2014 04:46 PM, John Alvord wrote:
>>
>>  I've been a lurker for a while and have recently been testing marpa on
>> a current project.
>>
>>  I am working with a mini-language which gets translated into SQL
>> finally. Here is a  minimal sample
>>
>> my $input="*IF *VALUE Log_Entries.Log_Name *EQ errlog ";
>>
>>  I created a gist here https://gist.github.com/jalvo2014/9575539 with a
>> test program. It includes a BNF file and [after debugging the BNF ] I put
>> an action on one of the rules and a routine to get control.
>>
>> <basic_condition>     ::= <basic_function> <attribute> <comparison>
>> <literal>   action => do_basic
>>
>> ...
>>
>>
>> $recce = Marpa::R2::Scanless::R->new(
>>         { grammar => $grammar,
>>           semantics_package => 'My_Actions',
>>           trace_terminals => 1,
>>           trace_values => 1,
>>         });
>>
>> ...
>>
>> sub My_Actions::do_basic {
>>     my ( undef, $t1, $t2, $t3, $t4 ) = @_;
>>     if (defined $t1) {
>> $DB::single=2;
>>     print "My_Actions::do_basic: $t1 $t2 $t3 $t4\n";
>>                 return undef;
>>     }
>> }
>>
>>  but when the do_basic gets control all the $t1/$t2/$t3/$t4 are undef.
>> After struggling for a week - likely on something simple - I could really
>> use some help.
>>
>>  Thanks.
>>
>>  John Alvord
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "marpa parser" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "marpa parser" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"marpa parser" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to