|
Class: XDRParser (in SunRPC)
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
parser for SunRPC XDR IDL declarations.
creates a list of XDRIDLTypes
CParser
CType
IDLType
IDLDatum
XDRIDLType
initialization
-
initialize
-
need this to autoload XDRIDLType (since its private classes are not autoloaded...)
instance creation
-
for: aStringOrStream
-
create & return a new cparser reading from aStringOrStream
-
new
-
create & return a new cparser
parsing
-
parse: aStringOrStream
-
parse declarations and defines.
Return the parser (which can be asked for types and defines).
-
parse: aStringOrStream withDefines: defines
-
parse declarations and defines.
Return the parser (which can be asked for types and defines).
-
parse: aStringOrStream withDefines: defines types: types
-
parse declarations and defines.
Return the parser (which can be asked for types and defines).
-
parse: aStringOrStream withTypes: types
-
parse declarations and types.
Return the parser (which can be asked for types and defines).
-
parseDefinition: aStringOrStream
-
parse a single definition.
Return a single type.
-
parsePrograms: aStringOrStream
-
parse a single definition.
Return a single type.
parsing-expressions
-
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)'
|
-
integerExpression: aStringOrStream withDefines: defines
-
parse an integer expression ..
Return the integer value or raise an error
-
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)'
|
-
parseIntegerExpression: aStringOrStream withDefines: defines
-
parse an integer expression ..
Return the integer value or raise an error
accessing
-
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)
-
constants
-
return the collection of constants (after parsing)
-
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)
-
defines
-
return the collection of defines (after parsing)
-
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)
-
programs
-
return the collection of programs (after parsing)
-
types
-
return the collection of types (after parsing)
-
types: aDictionary
-
set the collection of types (before parsing) - useful to parse more
accessing behaviour
-
ignoreRedefinitions
-
-
ignoreRedefinitions: aState
-
error handling
-
parseError: msg
-
a parse error occurred
initialization
-
initKnownTypes
-
types
-
initialize
-
defines isNil ifTrue:[
-
initializeFor: aStringOrStream
-
initialize the new scanner & prepare for reading from aStringOrStream
-
readSource: aStringOrStream
-
prepare for reading from aStringOrStream,
but do not reinitialize
-
scannerClass
-
parsing
-
builtInType
-
builtInType :=
[unsigned] int
| [unsigned] hyper
| [unsigned] long
| float
| double
| bool
-
compoundType
-
compoundType :=
'struct' <optional_name> '{' field_list '}'
'union' <optional_name> '{' field_list '}'
'enum' <optional_name> '{' field_list '}'
-
constant
-
-
constantDef
-
constValue := IDLDatum new type:type data:constValue.
-
declaration
-
-
definition
-
-
definitions
-
-
enumBody
-
fieldList := enumItem
| enumList enumItem
-
parseValue
-
-
procedureDef
-
-
programDef
-
-
structBody
-
-
typeDef
-
-
typeSpecifier
-
baseType := compoundType | builtInType
-
unionBodyFor: aType
-
-
versionDef
-
parsing-expressions
-
addExpression
-
e1 { '+' | '-' } e2
-
bitAndExpression
-
e1 '&' e2
-
bitOrExpression
-
e1 '|' e2
-
expression
-
-
mulExpression
-
e1 { '*' | '/' | '%' } e2
-
primary
-
- primary
~ primary
! primary
| ( expression )
| integer
| string
| identifier
-
shiftExpression
-
e1 { '<<' | '>>' } e2
private
-
declareType: aType name: anIdentifier
-
private - declare a typedef
scanning
-
expect: expectedToken
-
-
expectIdentifier
-
-
expectIdentifier: aString
-
-
nextToken
-
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;
'
|
|