[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

PPML question



I have a PPML question; I am now designing a metal definition, and most
of the things I need to do are working, with the exception of one thing:

My main language units are "entry"s which are divided up in two pieces:

<preamble>  <interact>

the reason they have to be divided up in such a way is that the 
preamble is always the same format, while the interact can be
very different, depending on the first identifier which follows the
preamble. In my grammar, I have 2 different kinds of interact at the
moment, one is a "sabme" and the other is a "ua". Later I will be adding
many others.

My problem is that in my ppml, for certain types of interactions, I would
like to output the value of one of the fields from the preamble in the
parameter list of the interaction. My PPML definition is this:

prettyprinter std of Lapd is

rules
*x !0 -> [<h> "..."];
entry(*preamb, *interact) -> [<h> *preamb *interact];
entry_s(**ents, *ent) -> [<v> (**ents) *ent];
preamble(*ts, *di, *cr) -> [<h> *di];

direction(*d) -> [<h> *d];
direction_usr -> [<v> ">> _Specifications@hp" "Acces1:"];
direction_net -> [<v> ">> _Liaison@hp" "Acces2:"];
fval(*v) -> [<h> *v];
pval(*v) -> [<h> *v];

sabme(*pval) -> [<v> "_Sabme" [<h> "{" *pval "}"]];
ua(*fval) -> [<v> "_Ua" [<h> "{" *fval "}"]];

end prettyprinter

At the moment, the parameters for SABME are just the "fval".
But what I would like to do is have the *cr field of the preamble (the
last field in the preamble) to be placed in sabme's parameter list
(between curly brackets). 

Example input:
06:32.5996  Usr 0  64  C SABME P=1
06:32.6544  Net 0  64  R UA    F=1

Desired output:
>> _Specifications@hp
Acces1:_Sabme
       {C 1} <<- the C is what I want, not what I have at the moment
>> _Liaison@hp
Acces2:_Ua
       {1}

How do I get an operand from the preamble operator to be "transmitted" to
the rule for sabme? Especially if I want to do it only for certain
interactions (sabme but not ua, for example)? Any assistance would be
greatly appreciated!

---------------------metal definition follows cut here-----------------

definition of Lapd is
   abstract syntax
      int  -> implemented as INTEGER ;
      letter  -> implemented as CHAR ;
      ident  -> implemented as IDENTIFIER ;

   rules
      <entrys> ::= <entrys> <entry> ;
         entry_s-post (<entrys>, <entry>)
      <entrys> ::= <entry> ;
         entry_s-list ((<entry>))
      <entry> ::= <preamble> <interact> ;
         entry (<preamble>, <interact>)
      <preamble> ::= <timestamp> <direction> <unknown> <unknown> <c_or_r> ;
         preamble (<timestamp>, <direction>, <c_or_r>)
      <ident> ::= %ID ;
         ident-atom(%ID)
      <int> ::= %NUM ;
         int-atom(%NUM)
      <letter> ::= %LET ;
         letter-atom(%LET)
      <min> ::= <int> ;
         min (<int>)
      <sec> ::= <int> ;
         sec (<int>)
      <msec> ::= <int> ;
         msec (<int>)
      <c_or_r> ::= <letter> ;
         c_or_r (<letter>)
      <timestamp> ::= <min> ":" <sec> "." <msec> ;
         timestamp (<min>, <sec>, <msec>)
      <direction_net> ::= "Net" ;
         direction_net ()
      <direction_usr> ::= "Usr" ;
         direction_usr ()
      <direction> ::= <direction_net>;
         direction(<direction_net>)
      <direction> ::= <direction_usr>;
         direction(<direction_usr>)
      <unknown> ::= <int> ;
         <int>
      <pval> ::= "P=" <int> ;
         pval (<int>)
      <fval> ::= "F=" <int> ;
         fval (<int>)
      <interact> ::= <sabme> ;
         <sabme>
      <interact> ::= <ua> ;
         <ua>
      <interact> ::= <foobar> ;
         <foobar>
      <sabme> ::= "SABME" <pval> ;
         sabme (<pval>)
      <ua> ::= "UA" <fval> ;
         ua (<fval>)
      <foobar> ::= "FOOBAR" <ident> ;
         foobar (<ident>)

   abstract syntax
      timestamp  -> MIN SEC MSEC ;
      entry_s  -> ENTRY + ... ;
      entry  -> PREAMBLE INTERACT ;
      preamble  -> TIMESTAMP DIRECTION C_OR_R ;
      sabme  -> PVAL ;
      foobar  -> IDENT ;
      c_or_r  -> LETTER ;
      ua  -> FVAL ;
      min  -> INT ;
      sec  -> INT ;
      msec  -> INT ;
      pval  -> INT ;
      fval  -> INT ;
      direction_net  -> implemented as SINGLETON ;
      direction_usr  -> implemented as SINGLETON ;
      direction -> NETUSR;      
      ENTRY_S  ::= entry_s ;
      ENTRY  ::= entry ;
      PREAMBLE  ::= preamble ;
      TIMESTAMP  ::= timestamp ;
      INTERACT  ::= sabme ua foobar ;
      C_OR_R  ::= c_or_r ;
      MIN  ::= min ;
      PVAL  ::= pval ;
      FVAL  ::= fval ;
      SEC  ::= sec ;
      MSEC  ::= msec ;
      NETUSR  ::= direction_net direction_usr;
      DIRECTION ::= direction;
      INT  ::= int ;
      IDENT  ::= ident ;
      LETTER  ::= letter ;
end definition

-- 
| Alan Ezust           ezust@iro.umontreal.ca      Montreal, Quebec, Canada |
|---------- Universite de Montreal    Departement d'informatique -----------|
  Tel. (514) 343-6111 ext. 3503                Fax. (514) 343-5834