eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'SunRPC::XDRParser':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: XDRParser (in SunRPC)


Inheritance:

   Object
   |
   +--SunRPC::XDRParser

Package:
stx:goodies/communication
Category:
Net-Communication-SunRPC-XDR_IDL
Version:
rev: 1.13 date: 2019/05/24 09:52:45
user: cg
file: SunRPC_XDRParser.st directory: goodies/communication
module: stx stc-classLibrary: communication
Author:
Claus Gittinger

Description:


parser for SunRPC XDR IDL declarations.

creates a list of XDRIDLTypes


Related information:

    CParser
    CType
    IDLType
    IDLDatum
    XDRIDLType

Class protocol:

initialization
o  initialize
need this to autoload XDRIDLType (since its private classes are not autoloaded...)

instance creation
o  for: aStringOrStream
create & return a new cparser reading from aStringOrStream

o  new
create & return a new cparser

parsing
o  parse: aStringOrStream
parse declarations and defines.
Return the parser (which can be asked for types and defines).

o  parse: aStringOrStream withDefines: defines
parse declarations and defines.
Return the parser (which can be asked for types and defines).

o  parse: aStringOrStream withDefines: defines types: types
parse declarations and defines.
Return the parser (which can be asked for types and defines).

o  parse: aStringOrStream withTypes: types
parse declarations and types.
Return the parser (which can be asked for types and defines).

o  parseDefinition: aStringOrStream
parse a single definition.
Return a single type.

o  parsePrograms: aStringOrStream
parse a single definition.
Return a single type.

parsing-expressions
o  integerExpression: aStringOrStream
parse an integer expression ..
Return the integer value or raise an error

usage example(s):

     CParser integerExpression:'(0x8000 | 0x7FFF)'
     CParser integerExpression:'(0x8000 - 1)'

o  integerExpression: aStringOrStream withDefines: defines
parse an integer expression ..
Return the integer value or raise an error

o  parseIntegerExpression: aStringOrStream
parse an integer expression ..
Return the integer value or raise an error

usage example(s):

     CParser parseIntegerExpression:'(0x8000 | 0x7FFF)'
     CParser parseIntegerExpression:'(0x8000 - 1)'

o  parseIntegerExpression: aStringOrStream withDefines: defines
parse an integer expression ..
Return the integer value or raise an error


Instance protocol:

accessing
o  anonymousTypes
return the collection of anonymousTypes (after parsing).
These are embedded types in structs/unions or enums without type-def.
(maybe useful to get an anonymous enums value)

o  constants
return the collection of constants (after parsing)

o  constants: aDictionary
set the collection of constants (before parsing).
Use this to start parsing with some predefined values
(i.e. like compiling with -Dfoo=value)

o  defines
return the collection of defines (after parsing)

o  defines: aDictionary
set the collection of defines (before parsing).
Use this to start parsing with some predefined values
(i.e. like compiling with -Dfoo=value)

o  programs
return the collection of programs (after parsing)

o  types
return the collection of types (after parsing)

o  types: aDictionary
set the collection of types (before parsing) - useful to parse more

accessing behaviour
o  ignoreRedefinitions

o  ignoreRedefinitions: aState

error handling
o  parseError: msg
a parse error occurred

initialization
o  initKnownTypes
types

o  initialize
defines isNil ifTrue:[

o  initializeFor: aStringOrStream
initialize the new scanner & prepare for reading from aStringOrStream

o  readSource: aStringOrStream
prepare for reading from aStringOrStream,
but do not reinitialize

o  scannerClass

parsing
o  builtInType
builtInType :=
[unsigned] int
| [unsigned] hyper
| [unsigned] long
| float
| double
| bool

o  compoundType
compoundType :=
'struct' <optional_name> '{' field_list '}'
'union' <optional_name> '{' field_list '}'
'enum' <optional_name> '{' field_list '}'

o  constant

o  constantDef
constValue := IDLDatum new type:type data:constValue.

o  declaration

o  definition

o  definitions

o  enumBody
fieldList := enumItem
| enumList enumItem

o  parseValue

o  procedureDef

o  programDef

o  structBody

o  typeDef

o  typeSpecifier
baseType := compoundType | builtInType

o  unionBodyFor: aType

o  versionDef

parsing-expressions
o  addExpression
e1 { '+' | '-' } e2

o  bitAndExpression
e1 '&' e2

o  bitOrExpression
e1 '|' e2

o  expression

o  mulExpression
e1 { '*' | '/' | '%' } e2

o  primary
- primary
~ primary
! primary
| ( expression )
| integer
| string
| identifier

o  shiftExpression
e1 { '<<' | '>>' } e2

private
o  declareType: aType name: anIdentifier
private - declare a typedef

scanning
o  expect: expectedToken

o  expectIdentifier

o  expectIdentifier: aString

o  nextToken


Examples:


parsing a single declaration: (inspect and look at types, etc.)
  |parser|

  parser := XDRParser parse:'

       const PMAP_PORT = 111;      /* portmapper port number */

       const IPPROTO_TCP = 6;      /* protocol number for TCP/IP */
       const IPPROTO_UDP = 17;     /* protocol number for UDP/IP */

       struct mapping {
          unsigned int prog;
          unsigned int vers;
          unsigned int prot;
          unsigned int port;
       };

       struct *pmaplist {
          mapping map;
          pmaplist next;
       };

       struct call_result {
          unsigned int port;
          opaque res<>;
       };

       struct call_args {
          unsigned int prog;
          unsigned int vers;
          unsigned int proc;
          opaque args<>;
       };

       program PMAP_PROG {
          version PMAP_VERS {
             void
             PMAPPROC_NULL(void)         = 0;

             bool
             PMAPPROC_SET(mapping)       = 1;

             bool
             PMAPPROC_UNSET(mapping)     = 2;

             unsigned int
             PMAPPROC_GETPORT(mapping)   = 3;

             pmaplist
             PMAPPROC_DUMP(void)         = 4;

             call_result
             PMAPPROC_CALLIT(call_args)  = 5;
          } = 2;
       } = 100000;
  '


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Fri, 19 Apr 2024 06:54:08 GMT