hi again.

ok, i now have a much pared down example that exhibits the
   problem -- at least with attempts to use '<<' in an exe
   block.

in the file below i have one pair of equivalent lines which
   can be hashed in/out (or deleted) to cause the problem.
the lines are 268 and 269 in the file (way below) and are:

o/______________________________
0\  cut here...
                                        | (($item[16] & 0x000003) *
1024)
#                                       | (($item[16] & 0x000003) << 10)
o/______________________________
0\  cut here...





with that configuration, it will run properly.
the resulting output is:

o/______________________________
0\  cut here...


                             1: ^M


                             2: b0_c(&pimm), b1_c(&pimm), b2_c(&pimm),
b3_c(&pimm), ^M

[0000]  400000000000

                             3:  sm_b0(&sm_serw[0]), sm_b1(&sm_serw[0]),
sm_b2(&sm_serw[0]), sm_b3(&sm_serw[0]);^M


                             4: b0_r(&pimm), b1_r(&pimm), b2_r(&pimm),
b3_r(&pimm), ^M

[0001]  400000000000

                             5:  sm_b0(&sm_serw[0]), sm_b1(&sm_serw[0]),
sm_b2(&sm_serw[0]), sm_b3(&sm_serw[0]);^M


                             6: ^M




end of source at LINE 7
o/______________________________
0\  cut here...





if, however, the hash is moved to line 268 the problem occurs.
since there's only one instruction and the requisite clauses have
   been lost and autoreplaced by <reject> tokens, the instruction
   parse also fails as one will see.
in that case i get this output:
o/______________________________
0\  cut here...
              Warning: Undefined (sub)rule "bus0_p_see_clause" used in a
                       production.
                (Hint: Will you be providing this rule later, or did you
                       perhaps misspell "bus0_p_see_clause"? Otherwise
it will
                       be treated as an immediate <reject>.)

              Warning: Undefined (sub)rule "bus0_update_clause" used in
a
                       production.
                (Hint: Will you be providing this rule later, or did you
                       perhaps misspell "bus0_update_clause"? Otherwise
it
                       will be treated as an immediate <reject>.)

              Warning: Undefined (sub)rule "bus1_p_see_clause" used in a
                       production.
                (Hint: Will you be providing this rule later, or did you
                       perhaps misspell "bus1_p_see_clause"? Otherwise
it will
                       be treated as an immediate <reject>.)

              Warning: Undefined (sub)rule "bus1_update_clause" used in
a
                       production.
                (Hint: Will you be providing this rule later, or did you
                       perhaps misspell "bus1_update_clause"? Otherwise
it
                       will be treated as an immediate <reject>.)

              Warning: Undefined (sub)rule "bus2_p_see_clause" used in a
                       production.
                (Hint: Will you be providing this rule later, or did you
                       perhaps misspell "bus2_p_see_clause"? Otherwise
it will
                       be treated as an immediate <reject>.)

              Warning: Undefined (sub)rule "bus2_update_clause" used in
a
                       production.
                (Hint: Will you be providing this rule later, or did you
                       perhaps misspell "bus2_update_clause"? Otherwise
it
                       will be treated as an immediate <reject>.)

              Warning: Undefined (sub)rule "bus3_p_see_clause" used in a
                       production.
                (Hint: Will you be providing this rule later, or did you
                       perhaps misspell "bus3_p_see_clause"? Otherwise
it will
                       be treated as an immediate <reject>.)

              Warning: Undefined (sub)rule "bus3_update_clause" used in
a
                       production.
                (Hint: Will you be providing this rule later, or did you
                       perhaps misspell "bus3_update_clause"? Otherwise
it
                       will be treated as an immediate <reject>.)

              Warning: Undefined (sub)rule "sm_b0123_see_clause" used in
a
                       production.
                (Hint: Will you be providing this rule later, or did you
                       perhaps misspell "sm_b0123_see_clause"? Otherwise
it
                       will be treated as an immediate <reject>.)


                             1: ^M


                             2: b0_c(&pimm), b1_c(&pimm), b2_c(&pimm),
b3_c(&pimm), ^M



INVALID INSTRUCTION DETECTED.

I got as far as finding ...i had just started!
   (going for anything i might recognise)

my last success ended at LINE 1 COL 1.
You might have a look at that
   last line, or at this line:

                             3:  sm_b0(&sm_serw[0]), sm_b1(&sm_serw[0]),
sm_b2(&sm_serw[0]), sm_b3(&sm_serw[0]);^M

skip 1 address, try to continue...


                             3:  sm_b0(&sm_serw[0]), sm_b1(&sm_serw[0]),
sm_b2(&sm_serw[0]), sm_b3(&sm_serw[0]);^M


                             4: b0_r(&pimm), b1_r(&pimm), b2_r(&pimm),
b3_r(&pimm), ^M



INVALID INSTRUCTION DETECTED.

I got as far as finding ...i had just started!
   (going for anything i might recognise)

my last success ended at LINE 3 COL 82.
You might have a look at that
   last line, or at this line:

                             5:  sm_b0(&sm_serw[0]), sm_b1(&sm_serw[0]),
sm_b2(&sm_serw[0]), sm_b3(&sm_serw[0]);^M

skip 1 address, try to continue...


                             5:  sm_b0(&sm_serw[0]), sm_b1(&sm_serw[0]),
sm_b2(&sm_serw[0]), sm_b3(&sm_serw[0]);^M


                             6: ^M



end of source at LINE 7
o/______________________________
0\  cut here...



so, there you have it: this was the acorn that caused me to wonder
   if the sky might be falling.
for completeness, i'm doing this all on a win/xp (yuk) pc with cygwin.
   $ perl -v
gives me:
   This is perl, v5.6.1 built for cygwin-multi

please let me know what you think about the problem.
thanks.
hwn

the complete pared down source file follows below.

o/______________________________
0\  cut here...
#!/usr/local/bin/perl # # mach grammar and assembler
#
# Module:  %M% mach.pl
# Version: %I% -- shift error test version
# Date:    %H%  05jun2003


# declarations section follows.


#need the following files

#use strict;
#use warnings;
#use diagnostics;

our @prog_src;
our $src_code;

use vars qw($opt_l);    # L is used in actions inside the grammar

# the machine has 48 bit instruction words, which are built up
#   in two halves.
use vars qw($Instruction_upper);
use vars qw($Instruction_lower);
use vars qw($Instruction_address);

use vars qw($LastPrintedLine);
use vars qw($LineToPrint);

use vars qw($LastSuccess);
use vars qw($LookingFor);






# declarations section has ended, grammar definition section follows.


use Parse::RecDescent;
use Data::Dumper;

$::RD_ERRORS = 1; # Make sure the parser dies when it encounters an error
$::RD_WARN   = 1; # Enable warnings. This will warn on unused rules &c.
$::RD_HINT   = 1; # Give out hints to help fix problems.





$mach_grammar = q
{



program_body :  instruction(s) program_body
                        {
                                $return = 1;
                        }
        |       instruction
                        {
                                $return = 1;
                        }
        |       end_of_input
                        {
                                print sprintf "\nend of source at LINE %d\n",
                                        $thisline;
                                exit;
                        }
        |       bad_instr program_body
                        {
#       |       bad_instr {undef}
                        }








bad_instr :     {
                        print sprintf "\nINVALID INSTRUCTION DETECTED.";
                        print sprintf "\n\n%s %s\n   (%s %s)\n",
                                "I got as far as finding", $main::LastSuccess,
                                "going for", $main::LookingFor;
                        $main::Instruction_address += 1;
                        print sprintf "\nmy last success ended at LINE %d COL %d.",
                                $thisline, $thiscolumn;
                        print sprintf "\nYou might have a look at that";
                        print sprintf "\n   last line, or at this line:";
                        print "\n\n                             ";
                        print sprintf "%d: %s",
                                $main::LastPrintedLine + 2,
                                @main::prog_src[$main::LastPrintedLine+1];
                        print sprintf "\nskip 1 address, try to continue...\n";
                }
                <resync:[^;]*[;]>







end_of_input :  /^\cD/
        |       /^\cZ/
        |       /__EOF__/








instruction :
        {
                # processing before the instruction
                #    clear instruction word
                #    print source code if needed
                # end with reject so actual processing continues

                $main::Instruction_upper = 0x0;
                $main::Instruction_lower = 0x0;
                $main::LastSuccess = "...i had just started!";
                $main::LookingFor = "anything i might recognise";
                if (defined($main::opt_l))
                {
                        while ($main::LastPrintedLine != $thisline)
                        {
                                $main::LastPrintedLine++;
                                print "\n\n                             ";
                                print sprintf "%d: %s",
                                        $main::LastPrintedLine + 1,
                                        @main::prog_src[$main::LastPrintedLine];
                        }
                }
        } <reject>


        |       valid_instruction
                {
                        # got a valid instruction
                        #   if listing is selected, print the address
                        #   print the instruction word

                        print sprintf "\n";
                        if (defined($main::opt_l))
                        {
                                print sprintf "[%4.4x]  ",
                                        $main::Instruction_address;
                        }
                        $main::Instruction_address += 1;

                        print sprintf "%6.6x", $main::Instruction_upper;
                        print sprintf "%6.6x", $main::Instruction_lower;
                        1;
                }

        |       
                {
                        print "\n";
                } <reject>









valid_instruction : 
        acu_config_cmd





# top level instruction constructions
# top level instruction constructions
# top level instruction constructions



acu_config_cmd :
                bus0_p_see_clause
                        {
                                $main::LastSuccess = "a bus0 'ptr see clause'";
                                $main::LookingFor = "a comma and a bus0 'update 
clause'";
                        }
                bus0_update_clause
                        {
                                $main::LastSuccess = "a bus0 'update clause'";
                                $main::LookingFor = "a comma'";
                        }
                ','
                        {
                                $main::LastSuccess = "a comma";
                                $main::LookingFor = "a bus1 'ptr see clause'";
                        }
                bus1_p_see_clause <commit>
                        {
                                $main::LastSuccess = "a bus1 'ptr see clause'";
                                $main::LookingFor = "a comma and a bus1 'update 
clause'";
                        }
                bus1_update_clause
                        {
                                $main::LastSuccess = "a bus1 'update clause'";
                                $main::LookingFor = "a comma'";
                        }
                ','
                        {
                                $main::LastSuccess = "a comma";
                                $main::LookingFor = "a bus2 'ptr see clause'";
                        }
                bus2_p_see_clause
                        {
                                $main::LastSuccess = "a bus2 'ptr see clause'";
                                $main::LookingFor = "a comma and a bus2 'update 
clause'";
                        }
                bus2_update_clause
                        {
                                $main::LastSuccess = "a bus2 'update clause'";
                                $main::LookingFor = "a comma'";
                        }
                ','
                        {
                                $main::LastSuccess = "a comma";
                                $main::LookingFor = "a bus3 'ptr see clause'";
                        }
                bus3_p_see_clause
                        {
                                $main::LastSuccess = "a bus3 'ptr see clause'";
                                $main::LookingFor = "a comma and a bus3 'update 
clause'";
                        }
                bus3_update_clause
                        {
                                $main::LastSuccess = "a bus3 'update clause'";
                                $main::LookingFor = "a comma'";
                        }
                ','
                        {
                                $main::LastSuccess = "a comma";
                                $main::LookingFor = "a sm_b0123 'see clause'";
                        }
                sm_b0123_see_clause
                        {
                                $main::LastSuccess = "a sm_b0123 'see clause'";
                                $main::LookingFor = "a semicolon";
                        }
                ';'
                        {
                                $main::Instruction_upper = 0x400000
                                        | ($item[1] / 16)
                                        | ($item[7] / 2)
                                        | ($item[14] / 512)
                                        | ($item[20] / 64)
                                        | ($item[26] & 0x00000F)
                                        ;
                                $main::Instruction_lower = 0x000000
                                        | ($item[3] / 2048)
                                        | ($item[10] / 128)
                                        | (($item[16] & 0xC00000) / 16384)
#                                       | (($item[16] & 0x000003) * 1024)
                                        | (($item[16] & 0x000003) << 10)
                                        | (($item[22] & 0xC00000) / 1024)
                                        | (($item[22] & 0x000003) * 16384)
                                        | ($item[26] & 0xFF0000)
                                        ;
                                1;
                        }




# end of top level instructions.








# sm_b0123_see_clause positioned for sm-i and acu cmds.
#    b3 is set for lo word bits 18:16
#    b2 is set for lo word bits 21:19
#    b1 is split hi/low msb translated to bit 0, lsbs to 23:22
#    b0 is set for hi word, so xlated into bits 3:1

sm_b0123_see_clause :
                sm_b0123_see_phrase
                ','
                        {
                                $main::LastSuccess = "a comma";
                                $main::LookingFor = "an sm_b0123 'see clause'";
                        }
                sm_b0123_see_clause
                        {
                                $return = ($item[1] | $item[4]);
                                1;
                        }
        |       sm_b0123_see_phrase
                        {
                                $return = $item[1];
                                1;
                        }








sm_b0123_see_phrase:
                /sm_b0/i <commit>
                        {
                                $main::LastSuccess = "the sm_b0 token";
                                $main::LookingFor = "an open parenthesis";
                        }
                sm_b0123_see_item
                        {
                                $return = ($item[4] * 2);
                                1;
                        }
        |       /sm_b1/i <commit>
                        {
                                $main::LastSuccess = "the sm_b1 token";
                                $main::LookingFor = "an open parenthesis";
                        }
                sm_b0123_see_item
                        {
                                $return = ($item[4] * 4194304);
                                1;
                        }
        |       /sm_b2/i <commit>
                        {
                                $main::LastSuccess = "the sm_b2 token";
                                $main::LookingFor = "an open parenthesis";
                        }
                sm_b0123_see_item
                        {
                                $return = ($item[4] * 524288);
                                1;
                        }
        |       /sm_b3/i <commit>
                        {
                                $main::LastSuccess = "the sm_b3 token";
                                $main::LookingFor = "an open parenthesis";
                        }
                sm_b0123_see_item
                        {
                                $return = ($item[4] * 65536);
                                1;
                        }






sm_b0123_see_item :
                '('
                        {
                                $main::LastSuccess = "an open parenthesis";
                                $main::LookingFor = "an '&' ampersand";
                        }
                '&'
                        {
                                $main::LastSuccess = "an '&' ampersand";
                                $main::LookingFor = "a b-bus input";
                        }
                smb_ins
                        {
                                $main::LastSuccess = "a b-bus input";
                                $main::LookingFor = "a close parenthesis";
                        }
                ')'
                        {
                                $return = $item[5] * 2;
                                1;
                        }





smb_ins :       /sm_serw/i '[' octal_digit ']'  { $return = $item[3]; 1; }


























bus0_p_see_clause :
                bus0_see_phrase
                        {
                                $main::LastSuccess = "a 'see phrase' for bus0";
                                $main::LookingFor = "a comma";
                        }
                ','
                        {
                                $main::LastSuccess = "a comma";
                                $main::LookingFor = "a bus0 'ptr see clause' probably";
                        }
                bus0_p_see_clause
                        {
                                $main::LastSuccess = "a 'see clause' for bus0";
                                $main::LookingFor = "a comma probably";
                                $return = $item[1] | $item[5];
                                1;
                        }
        |               bus0_see_phrase
                        {
                                $main::LastSuccess = "a 'see clause' for b0";
                                $main::LookingFor = "an 'op clause' probably";
                                $return = $item[1];
                                1;
                        }

bus0_see_phrase:        bus0_see_c      { $return = $item[1]; 1; }
        |               bus0_see_r      { $return = $item[1]; 1; }
                



# b0?_ins are positioned for proper loc in hi word of acu immediate instructions

bus0_see_c :    /b0_c/i
                        {
                                $main::LastSuccess = "the b0_c register token";
                                $main::LookingFor = "an open parenthesis";
                        }
                '(' <commit>
                        {
                                $main::LastSuccess = "an open parenthesis";
                                $main::LookingFor = "an '&' ampersand";
                        }
                '&'
                        {
                                $main::LastSuccess = "an '&' ampersand";
                                $main::LookingFor = "an input source for b0_c";
                        }
                /pimm/i
                        {
                                $main::LastSuccess = "an input for b0_c";
                                $main::LookingFor = "a close parenthesis";
                        }
                ')'
                        {
                                $return = $item[8];
                                1;
                        }


bus0_see_r :    /b0_r/i
                        {
                                $main::LastSuccess = "the b0_r register token";
                                $main::LookingFor = "an open parenthesis";
                        }
                '(' <commit>
                        {
                                $main::LastSuccess = "an open parenthesis";
                                $main::LookingFor = "an '&' ampersand";
                        }
                '&'
                        {
                                $main::LastSuccess = "an '&' ampersand";
                                $main::LookingFor = "an input source for b0_r";
                        }
                /pimm/i
                        {
                                $main::LastSuccess = "an input for b0_r";
                                $main::LookingFor = "a close parenthesis";
                        }
                ')'
                        {
                                $return = $item[8];
                                1;
                        }






# bus0 -- the "update" clauses to tell what registers get changed

#     note: update phrases can be empty, so separating comma moved in.


# bus0_update_clause positioned for acu-immediate instr

bus0_update_clause :
                ','
                        {
                                $main::LastSuccess = "a comma";
                                $main::LookingFor = "a bus0 update item, likely";
                        }
                bus0_update_item
                        {
                                $main::LastSuccess = "a bus0 update item";
                                $main::LookingFor = "a bus0 update clause, likely";
                        }
                bus0_update_clause
                        {
                                $return = $item[3] | $item[5];
                                1;
                        }
        |       ','
                        {
                                $main::LastSuccess = "a comma";
                                $main::LookingFor = "a bus0 update item, likely";
                        }
                bus0_update_item
                        {
                                $main::LastSuccess = "a bus0 update item";
                                $main::LookingFor = "something after a bus0 update 
clause";
                                $return = $item[3];
                                1;
                        }
        |               { $return = 0; 1; }




bus0_update_item :
                /b0_c/i
                        {
                                $main::LastSuccess = "a keyword b0_c";
                                $main::LookingFor = "an update phrase";
                        }
                update_phrase
                        {
                                $return = 0x000800;
                                1;
                        }
        |       /b0_r/i
                        {
                                $main::LastSuccess = "a keyword b0_r";
                                $main::LookingFor = "an update phrase";
                        }
                update_phrase
                        {
                                $return = 0x001000;
                                1;
                        }

























bus1_p_see_clause :
                bus1_see_phrase
                        {
                                $main::LastSuccess = "a 'see phrase' for bus1";
                                $main::LookingFor = "a comma";
                        }
                ','
                        {
                                $main::LastSuccess = "a comma";
                                $main::LookingFor = "a bus1 'ptr see clause' probably";
                        }
                bus1_p_see_clause
                        {
                                $main::LastSuccess = "a 'see clause' for bus1";
                                $main::LookingFor = "a comma probably";
                                $return = $item[1] | $item[5];
                                1;
                        }
        |               bus1_see_phrase
                        {
                                $main::LastSuccess = "a 'see clause' for b1";
                                $main::LookingFor = "an 'op clause' probably";
                                $return = $item[1];
                                1;
                        }



bus1_see_phrase:        bus1_see_c      { $return = $item[1]; 1; }
        |               bus1_see_r      { $return = $item[1]; 1; }
                



# b1?_ins are positioned for proper loc in hi word of acu immediate instructions

bus1_see_c :    /b1_c/i
                        {
                                $main::LastSuccess = "the b1_c register token";
                                $main::LookingFor = "an open parenthesis";
                        }
                '(' <commit>
                        {
                                $main::LastSuccess = "an open parenthesis";
                                $main::LookingFor = "an '&' ampersand";
                        }
                '&'
                        {
                                $main::LastSuccess = "an '&' ampersand";
                                $main::LookingFor = "an input source for b1_c";
                        }
                /pimm/i
                        {
                                $main::LastSuccess = "an input for b1_c";
                                $main::LookingFor = "a close parenthesis";
                        }
                ')'
                        {
                                $return = $item[8];
                                1;
                        }


bus1_see_r :    /b1_r/i
                        {
                                $main::LastSuccess = "the b1_r register token";
                                $main::LookingFor = "an open parenthesis";
                        }
                '(' <commit>
                        {
                                $main::LastSuccess = "an open parenthesis";
                                $main::LookingFor = "an '&' ampersand";
                        }
                '&'
                        {
                                $main::LastSuccess = "an '&' ampersand";
                                $main::LookingFor = "an input source for b1_r";
                        }
                /pimm/i
                        {
                                $main::LastSuccess = "an input for b1_r";
                                $main::LookingFor = "a close parenthesis";
                        }
                ')'
                        {
                                $return = $item[8];
                                1;
                        }














# bus1 -- the "update" clauses to tell what registers get changed

#     note: update phrases can be empty, so separating comma moved in.


# bus1_update_clause positioned for acu-immediate instr

bus1_update_clause :
                ','
                        {
                                $main::LastSuccess = "a comma";
                                $main::LookingFor = "a bus1 update item, likely";
                        }
                bus1_update_item
                        {
                                $main::LastSuccess = "a bus1 update item";
                                $main::LookingFor = "a bus1 update clause, likely";
                        }
                bus1_update_clause
                        {
                                $return = $item[3] | $item[5];
                                1;
                        }
        |       ','
                        {
                                $main::LastSuccess = "a comma";
                                $main::LookingFor = "a bus1 update item, likely";
                        }
                bus1_update_item
                        {
                                $main::LastSuccess = "a bus1 update item";
                                $main::LookingFor = "something after a bus1 update 
clause";
                                $return = $item[3];
                                1;
                        }
        |               { $return = 0; 1; }




bus1_update_item :
                /b1_c/i
                        {
                                $main::LastSuccess = "a keyword b1_c";
                                $main::LookingFor = "an update phrase";
                        }
                update_phrase
                        {
                                $return = 0x000800;
                                1;
                        }
        |       /b1_r/i
                        {
                                $main::LastSuccess = "a keyword b1_r";
                                $main::LookingFor = "an update phrase";
                        }
                update_phrase
                        {
                                $return = 0x001000;
                                1;
                        }



















bus2_p_see_clause :
                bus2_see_phrase
                        {
                                $main::LastSuccess = "a 'see phrase' for bus2";
                                $main::LookingFor = "a comma";
                        }
                ','
                        {
                                $main::LastSuccess = "a comma";
                                $main::LookingFor = "a bus2 'ptr see clause' probably";
                        }
                bus2_p_see_clause
                        {
                                $main::LastSuccess = "a 'see clause' for bus2";
                                $main::LookingFor = "a comma probably";
                                $return = $item[1] | $item[5];
                                1;
                        }
        |               bus2_see_phrase
                        {
                                $main::LastSuccess = "a 'see clause' for b2";
                                $main::LookingFor = "an 'op clause' probably";
                                $return = $item[1];
                                1;
                        }



bus2_see_phrase:        bus2_see_c      { $return = $item[1]; 1; }
        |               bus2_see_r      { $return = $item[1]; 1; }
                



# b2?_ins are positioned for proper loc in lo word of acu immediate instructions

bus2_see_c :    /b2_c/i
                        {
                                $main::LastSuccess = "the b2_c register token";
                                $main::LookingFor = "an open parenthesis";
                        }
                '(' <commit>
                        {
                                $main::LastSuccess = "an open parenthesis";
                                $main::LookingFor = "an '&' ampersand";
                        }
                '&'
                        {
                                $main::LastSuccess = "an '&' ampersand";
                                $main::LookingFor = "an input source for b2_c";
                        }
                /pimm/i
                        {
                                $main::LastSuccess = "an input for b2_c";
                                $main::LookingFor = "a close parenthesis";
                        }
                ')'
                        {
                                $return = $item[8];
                                1;
                        }


bus2_see_r :    /b2_r/i
                        {
                                $main::LastSuccess = "the b2_r register token";
                                $main::LookingFor = "an open parenthesis";
                        }
                '(' <commit>
                        {
                                $main::LastSuccess = "an open parenthesis";
                                $main::LookingFor = "an '&' ampersand";
                        }
                '&'
                        {
                                $main::LastSuccess = "an '&' ampersand";
                                $main::LookingFor = "an input source for b2_r";
                        }
                /pimm/i
                        {
                                $main::LastSuccess = "an input for b2_r";
                                $main::LookingFor = "a close parenthesis";
                        }
                ')'
                        {
                                $return = $item[8];
                                1;
                        }












# bus2 -- the "update" clauses to tell what registers get changed

#     note: update phrases can be empty, so separating comma moved in.


# bus2_update_clause positioned for acu-immediate instr.
#    bus2_update_clause is split msb xlate to 1:0, lsbs to 23:22

bus2_update_clause :
                ','
                        {
                                $main::LastSuccess = "a comma";
                                $main::LookingFor = "a bus2 update item, likely";
                        }
                bus2_update_item
                        {
                                $main::LastSuccess = "a bus2 update item";
                                $main::LookingFor = "a bus2 update clause, likely";
                        }
                bus2_update_clause
                        {
                                $return = $item[3] | $item[5];
                                1;
                        }
        |       ','
                        {
                                $main::LastSuccess = "a comma";
                                $main::LookingFor = "a bus2 update item, likely";
                        }
                bus2_update_item
                        {
                                $main::LastSuccess = "a bus2 update item";
                                $main::LookingFor = "something after a bus2 update 
clause";
                                $return = $item[3];
                                1;
                        }
        |               { $return = 0; 1; }




bus2_update_item :
                /b2_c/i
                        {
                                $main::LastSuccess = "a keyword b2_c";
                                $main::LookingFor = "an update phrase";
                        }
                update_phrase
                        {
                                $return = 0x400000;
                                1;
                        }
        |       /b2_r/i
                        {
                                $main::LastSuccess = "a keyword b2_r";
                                $main::LookingFor = "an update phrase";
                        }
                update_phrase
                        {
                                $return = 0x800000;
                                1;
                        }






















bus3_p_see_clause :
                bus3_see_phrase
                        {
                                $main::LastSuccess = "a 'see phrase' for bus3";
                                $main::LookingFor = "a comma";
                        }
                ','
                        {
                                $main::LastSuccess = "a comma";
                                $main::LookingFor = "a bus3 'ptr see clause' probably";
                        }
                bus3_p_see_clause
                        {
                                $main::LastSuccess = "a 'see clause' for bus3";
                                $main::LookingFor = "a comma probably";
                                $return = $item[1] | $item[5];
                                1;
                        }
        |               bus3_see_phrase
                        {
                                $main::LastSuccess = "a 'see clause' for b3";
                                $main::LookingFor = "an 'op clause' probably";
                                $return = $item[1];
                                1;
                        }










bus3_see_phrase:        bus3_see_c      { $return = $item[1]; 1; }
        |               bus3_see_r      { $return = $item[1]; 1; }
                



# b3?_ins are positioned for proper loc in lo word of acu immediate instructions

bus3_see_c :    /b3_c/i
                        {
                                $main::LastSuccess = "the b3_c register token";
                                $main::LookingFor = "an open parenthesis";
                        }
                '(' <commit>
                        {
                                $main::LastSuccess = "an open parenthesis";
                                $main::LookingFor = "an '&' ampersand";
                        }
                '&'
                        {
                                $main::LastSuccess = "an '&' ampersand";
                                $main::LookingFor = "an input source for b3_c";
                        }
                /pimm/i
                        {
                                $main::LastSuccess = "an input for b3_c";
                                $main::LookingFor = "a close parenthesis";
                        }
                ')'
                        {
                                $return = $item[8];
                                1;
                        }


bus3_see_r :    /b3_r/i
                        {
                                $main::LastSuccess = "the b3_r register token";
                                $main::LookingFor = "an open parenthesis";
                        }
                '(' <commit>
                        {
                                $main::LastSuccess = "an open parenthesis";
                                $main::LookingFor = "an '&' ampersand";
                        }
                '&'
                        {
                                $main::LastSuccess = "an '&' ampersand";
                                $main::LookingFor = "an input source for b3_r";
                        }
                /pimm/i
                        {
                                $main::LastSuccess = "an input for b3_r";
                                $main::LookingFor = "a close parenthesis";
                        }
                ')'
                        {
                                $return = $item[8];
                                1;
                        }






# bus3 -- the "update" clauses to tell what registers get changed

#     note: update phrases can be empty, so separating comma moved in.


# bus3_update_clause positioned for acu-immediate instr.
#    bus3_update_clause is split msb xlate to 1:0, lsbs to 23:22

bus3_update_clause :
                ','
                        {
                                $main::LastSuccess = "a comma";
                                $main::LookingFor = "a bus3 update item, likely";
                        }
                bus3_update_item
                        {
                                $main::LastSuccess = "a bus3 update item";
                                $main::LookingFor = "a bus3 update clause, likely";
                        }
                bus3_update_clause
                        {
                                $return = $item[3] | $item[5];
                                1;
                        }
        |       ','
                        {
                                $main::LastSuccess = "a comma";
                                $main::LookingFor = "a bus3 update item, likely";
                        }
                bus3_update_item
                        {
                                $main::LastSuccess = "a bus3 update item";
                                $main::LookingFor = "something after a bus3 update 
clause";
                                $return = $item[2];
                                1;
                        }
        |               { $return = 0; 1; }







bus3_update_item :
                /b3_c/i
                        {
                                $main::LastSuccess = "a keyword b3_c";
                                $main::LookingFor = "an update phrase";
                        }
                update_phrase
                        {
                                $return = 0x400000;
                                1;
                        }
        |       /b3_r/i
                        {
                                $main::LastSuccess = "a keyword b3_r";
                                $main::LookingFor = "an update phrase";
                        }
                update_phrase
                        {
                                $return = 0x800000;
                                1;
                        }







update_phrase:  '(' /next/i ')' { $return = 0; 1 }






on :            /on/i           { $return = 1; 1; }

zero :          /0/             { $return = 0; 1; }
        |       /zero/i         { $return = 0; 1; }


one :           /1/             { $return = 1; 1; }
        |       /one/i          { $return = 1; 1; }


two :           /2/             { $return = 2; 1; }


octal_digit :   /[0-7]/         { $return = $item[1]; 1; }




};

# grammar section has ended,
#  main program section follows.

{

$opt_l = 1;     # force listing in actions inside the grammar

my $mach_parser = new Parse::RecDescent ($mach_grammar); 


$Instruction_upper = 0x0;
$Instruction_lower = 0x0;
$Instruction_address = 0;
$LastPrintedLine = -1;






# acquire @prog_src

        @prog_src = <DATA> or die "ERROR: cannot read input data.";

#
# mash all the source together and remove all the newlines.
#

foreach (0 .. scalar(@prog_src) - 1)
{
        [EMAIL PROTECTED] =~ s/\\r/\$\//g ;
}

push @prog_src, "\n__EOF__";

$src_code = join " ", @prog_src;

defined $mach_parser->program_body($src_code) or die "bad grammar!";


}
#
# ******************************************************************
# main program section has ended, debug data section follows.
# ******************************************************************
#

__DATA__

b0_c(&pimm), b1_c(&pimm), b2_c(&pimm), b3_c(&pimm), 
 sm_b0(&sm_serw[0]), sm_b1(&sm_serw[0]), sm_b2(&sm_serw[0]), sm_b3(&sm_serw[0]);
b0_r(&pimm), b1_r(&pimm), b2_r(&pimm), b3_r(&pimm), 
 sm_b0(&sm_serw[0]), sm_b1(&sm_serw[0]), sm_b2(&sm_serw[0]), sm_b3(&sm_serw[0]);

__EOF__



Reply via email to