|
Class: XDRParser (in SunRPC)
Object
|
+--SunRPC::XDRParser
- Package:
- stx:goodies/communication
- Category:
- Net-Communication-SunRPC-XDR_IDL
- Version:
- rev:
1.15
date: 2021/01/20 13:18:44
- user: cg
- file: SunRPC_XDRParser.st directory: goodies/communication
- module: stx stc-classLibrary: communication
parser for SunRPC XDR IDL declarations.
creates a list of XDRIDLTypes
copyrightCOPYRIGHT (c) 2002 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
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
Usage example(s):
|defines|
defines := Dictionary new.
defines at:'VAL1' put:'0x100'.
defines at:'VAL2' put:'0x200'.
CParser integerExpression:'(VAL1 + VAL2 - 1)' withDefines:defines
|
Usage example(s):
|defines|
defines := Dictionary new.
defines at:'VAL1' put:'0x100 // MAGIC 1'.
defines at:'VAL2' put:'0x200 // MAGIC 2'.
CParser integerExpression:'(VAL1 + VAL2 - 1)' withDefines:defines
|
Usage example(s):
|parser defines|
parser := CParser parse:'
#define FOO 0xFF00
#define BAR 1
'.
defines := parser defines.
CParser integerExpression:'FOO | BAR' withDefines:defines.
|
-
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;
'
|
|