Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members

CCM::CSharpParser Class Reference

List of all members.

Detailed Description

C#-Parser class.

The guts of this class are automatically generated by jay from the grammar rules and semantics below.


Public Types

enum  Modifiers { PUBLIC, STATIC }
 Relevant modifiers. More...


Public Member Functions

 CSharpParser (Hashtable classes)
 Initialize the parser.

void yyerror (string message)
 simplified error message.

void yyerror (string message, string[] expected)
 (syntax) error message.

Object yyparse (yyParser.yyInput yyLex, Object yyd)
 the generated parser, with debugging messages.

Object yyparse (yyParser.yyInput yyLex)
 the generated parser.

bool parse (TextReader reader, string fname)
 Parse a C# module.


Protected Member Functions

string[] yyExpecting (int state)
 computes list of expected tokens on error by tracing the tables.

Object yyDefault (Object first)
 executed at the beginning of a reduce action.


Protected Attributes

int yyMax
 initial size and increment of the state/value stack [default 256].


Static Protected Attributes

int yyFinal = 4
 debugging support, requires the package jay.yydebug.

string[] yyNames
short[] yyDgoto
short[] yySindex
short[] yyRindex
short[] yyGindex
short[] yyTable
short[] yyCheck

Private Member Functions

VariableDecl resolveVar (Ref r)
 Resolve given reference to a VariableDecl (block variable, method parameter, class field).

Method resolveMethod (Ref r, IList args)
 Resolve given reference to a Method.

Expr makeRefExpr (VariableDecl v, Ref r)
 Create a reference expression to a given variable declaration.

Expr makeAssign (Object a, Expr e)
 Create and return an assignment expression for a = e.

Expr makeRefAssign (Ref r, Expr e)
 Return an assignment Expression for r = e.

Expr makeCall (Ref r, Method m, List pars)
 Return a method call expression for m(pars).

void chkb (Object o)
 Assert that given object is a boolean expression and report error if not.

void chki (Object o)
 Assert that given object is an integer expression and report error if not.

void chkf (Object o)
 Assert that given object is a double expression and report error if not.

void chks (Object o)
 Assert that given object is a string expression and report error if not.

void chksametype (Object o1, Object o2)
 Assert that given objects are expressions of the same type and report an error if not.

void errNumExp ()
 Error report: numeric expression expected.

void errAssignmentTypeMismatch ()
 Error report: assignment type mismatch.

void errNotAssignable (Expr e)
 Error report: expression is not assignable.

void errUnknownType ()
 Error report: unknown type.

void errBreakContNoLoop ()
 Error report: break or continue used outside of a loop.

void errUndeclaredId (string id)
 Error report: undeclared identifier.

void errVoidReturn ()
 Error report: return without value in non-void method.

void errNoVoidReturn ()
 Error report: return with value in void method.

void errReturnType ()
 Error report: return value does not match method return type.

void errWrongCallParams ()
 Error report: incompatible arguments in method call.

void errNewType ()
 Error report: new must be used with class types.

void errNewSyntax ()
 Error report: syntax error in new expression.

void errNonArrayElementAccess (string e)
 Error report: element access of non-array expression.

void errNoMatchingCtor ()
 Error report: no matching constructor for given arguments.

void errStaticCtor ()
 Error report: static constructor is forbidden.

void errNonStaticMethod ()
 Error report: nonstatic method called of static class reference.

void errDuplicateMethod ()
 Error report: ambiguous method declaration.

void errUnimplOp ()
 Error report: unimplemented operator.

void errClassBase ()
 Error report: invalid class ancestor.

void errStubTypeForbidden ()
 Error report: stubs are invalid as local block variables.

void errNonStubMember (string var)
 Error report: member access of non-stub expression.

void errOneDimArrayAccess ()
 Error report: currently supports only one-dimensional arrays.


Private Attributes

Block currBlock
 Currently constructed and parsed statement block.

Type currDeclType
 Type of the most recent member/variable declaration.

Class stubDeclClass
 Particular stub class if currDeclType == stubType.

int arrayDeclDim
 Size of the recently declared array if currDeclType == arrayType.

Type arrayElementType
 Element type of the recently declared array if currDeclType == arrayType.

Method currMethod
 Currently constructed and parsed method.

Class currClass
 Currently constructed and parsed class.

Attribute currAttr
 Currently constructed attribute in attribute list.

List attributes
 Attributes of the most recent declaration.

int loopDepth
 Current loop depth.

Hashtable classes
 Dictionary (string -> Class) of all known classes.

IList modifiers
 Modifiers of the most recent declaration.

Tokenizer lexer
 C# scanner (lexical analysis).


Static Private Attributes

Type stubType = ( new Class("", null, "" ) ).GetType()
 Stub type constant for easier comparisons.

Type arrayType = ( new List() ).GetType()
 Array type constant for easier comparisons.

short[] yyLhs
short[] yyLen
short[] yyDefRed


Member Enumeration Documentation

enum CCM::CSharpParser::Modifiers
 

Relevant modifiers.

Enumeration values:
PUBLIC 
STATIC 


Constructor & Destructor Documentation

CCM::CSharpParser::CSharpParser Hashtable  classes  ) 
 

Initialize the parser.

Parameters:
classes Dictionary (string -> Class) of already parsed classes; parsed classes are added to this.


Member Function Documentation

void CCM::CSharpParser::chkb Object  o  )  [private]
 

Assert that given object is a boolean expression and report error if not.

void CCM::CSharpParser::chkf Object  o  )  [private]
 

Assert that given object is a double expression and report error if not.

void CCM::CSharpParser::chki Object  o  )  [private]
 

Assert that given object is an integer expression and report error if not.

void CCM::CSharpParser::chks Object  o  )  [private]
 

Assert that given object is a string expression and report error if not.

void CCM::CSharpParser::chksametype Object  o1,
Object  o2
[private]
 

Assert that given objects are expressions of the same type and report an error if not.

void CCM::CSharpParser::errAssignmentTypeMismatch  )  [private]
 

Error report: assignment type mismatch.

void CCM::CSharpParser::errBreakContNoLoop  )  [private]
 

Error report: break or continue used outside of a loop.

void CCM::CSharpParser::errClassBase  )  [private]
 

Error report: invalid class ancestor.

void CCM::CSharpParser::errDuplicateMethod  )  [private]
 

Error report: ambiguous method declaration.

void CCM::CSharpParser::errNewSyntax  )  [private]
 

Error report: syntax error in new expression.

void CCM::CSharpParser::errNewType  )  [private]
 

Error report: new must be used with class types.

void CCM::CSharpParser::errNoMatchingCtor  )  [private]
 

Error report: no matching constructor for given arguments.

void CCM::CSharpParser::errNonArrayElementAccess string  e  )  [private]
 

Error report: element access of non-array expression.

void CCM::CSharpParser::errNonStaticMethod  )  [private]
 

Error report: nonstatic method called of static class reference.

void CCM::CSharpParser::errNonStubMember string  var  )  [private]
 

Error report: member access of non-stub expression.

void CCM::CSharpParser::errNotAssignable Expr  e  )  [private]
 

Error report: expression is not assignable.

void CCM::CSharpParser::errNoVoidReturn  )  [private]
 

Error report: return with value in void method.

void CCM::CSharpParser::errNumExp  )  [private]
 

Error report: numeric expression expected.

void CCM::CSharpParser::errOneDimArrayAccess  )  [private]
 

Error report: currently supports only one-dimensional arrays.

void CCM::CSharpParser::errReturnType  )  [private]
 

Error report: return value does not match method return type.

void CCM::CSharpParser::errStaticCtor  )  [private]
 

Error report: static constructor is forbidden.

void CCM::CSharpParser::errStubTypeForbidden  )  [private]
 

Error report: stubs are invalid as local block variables.

void CCM::CSharpParser::errUndeclaredId string  id  )  [private]
 

Error report: undeclared identifier.

void CCM::CSharpParser::errUnimplOp  )  [private]
 

Error report: unimplemented operator.

void CCM::CSharpParser::errUnknownType  )  [private]
 

Error report: unknown type.

void CCM::CSharpParser::errVoidReturn  )  [private]
 

Error report: return without value in non-void method.

void CCM::CSharpParser::errWrongCallParams  )  [private]
 

Error report: incompatible arguments in method call.

Expr CCM::CSharpParser::makeAssign Object  a,
Expr  e
[private]
 

Create and return an assignment expression for a = e.

Parameters:
a assignable expression; it is just an object, so that invocations from the parser rules can be written without a typecast
e expression which is assigned to a

Expr CCM::CSharpParser::makeCall Ref  r,
Method  m,
List  pars
[private]
 

Return a method call expression for m(pars).

Expr CCM::CSharpParser::makeRefAssign Ref  r,
Expr  e
[private]
 

Return an assignment Expression for r = e.

Needed for local variable initializers, where there is no left-hand expression.

Expr CCM::CSharpParser::makeRefExpr VariableDecl  v,
Ref  r
[private]
 

Create a reference expression to a given variable declaration.

Note that we cannot directly save v into a Ref since at runtime the IDs will resolve to different variables.

bool CCM::CSharpParser::parse TextReader  reader,
string  fname
 

Parse a C# module.

Classes are added to the list given in the constructor.

Parameters:
reader input TextReader that contains file to be parsed
fname file name of reader to give proper error messages
Returns:
true on success or false if given reader cannot be parsed as C# module

Method CCM::CSharpParser::resolveMethod Ref  r,
IList  args
[private]
 

Resolve given reference to a Method.

VariableDecl CCM::CSharpParser::resolveVar Ref  r  )  [private]
 

Resolve given reference to a VariableDecl (block variable, method parameter, class field).

We cannot use Ref.resolve() for that since there is not yet a method call stack, nor a Class.getCurrentClass(). This also checks if an ID is allowed at the calling place at all (i. e. field initializers must be constant expressions), and that non-stub QIDs must be unqualified (restriction in cs2ccmb since we only deal with one class).

Object CCM::CSharpParser::yyDefault Object  first  )  [protected]
 

executed at the beginning of a reduce action.

Used as $$ = yyDefault($1), prior to the user-specified action, if any. Can be overwritten to provide deep copy, etc.

Parameters:
first value for $1, or null.
Returns:
first.

void CCM::CSharpParser::yyerror string  message,
string[]  expected
 

(syntax) error message.

Can be overwritten to control message format.

Parameters:
message text to be displayed.
expected vector of acceptable tokens, if available.

void CCM::CSharpParser::yyerror string  message  ) 
 

simplified error message.

See also:
yyerror

string [] CCM::CSharpParser::yyExpecting int  state  )  [protected]
 

computes list of expected tokens on error by tracing the tables.

Parameters:
state for which to compute the list.
Returns:
list of token names.

Object CCM::CSharpParser::yyparse yyParser.yyInput  yyLex  ) 
 

the generated parser.

Maintains a state and a value stack, currently with fixed maximum size.

Parameters:
yyLex scanner.
Returns:
result of the last reduction, if any.
Exceptions:
yyException on irrecoverable parse error.

Object CCM::CSharpParser::yyparse yyParser.yyInput  yyLex,
Object  yyd
 

the generated parser, with debugging messages.

Maintains a state and a value stack, currently with fixed maximum size.

Parameters:
yyLex scanner.
yydebug debug message writer implementing yyDebug, or null.
Returns:
result of the last reduction, if any.
Exceptions:
yyException on irrecoverable parse error.


Member Data Documentation

int CCM::CSharpParser::arrayDeclDim [private]
 

Size of the recently declared array if currDeclType == arrayType.

Type CCM::CSharpParser::arrayElementType [private]
 

Element type of the recently declared array if currDeclType == arrayType.

Type CCM::CSharpParser::arrayType = ( new List() ).GetType() [static, private]
 

Array type constant for easier comparisons.

List CCM::CSharpParser::attributes [private]
 

Attributes of the most recent declaration.

This is required since there can be more than one field in one declaration and we cannot pass the attributes directly as arguments "down" the rules.

Hashtable CCM::CSharpParser::classes [private]
 

Dictionary (string -> Class) of all known classes.

Attribute CCM::CSharpParser::currAttr [private]
 

Currently constructed attribute in attribute list.

Block CCM::CSharpParser::currBlock [private]
 

Currently constructed and parsed statement block.

Class CCM::CSharpParser::currClass [private]
 

Currently constructed and parsed class.

Type CCM::CSharpParser::currDeclType [private]
 

Type of the most recent member/variable declaration.

Method CCM::CSharpParser::currMethod [private]
 

Currently constructed and parsed method.

Tokenizer CCM::CSharpParser::lexer [private]
 

C# scanner (lexical analysis).

int CCM::CSharpParser::loopDepth [private]
 

Current loop depth.

Used to determine the validity of a break/continue statement.

IList CCM::CSharpParser::modifiers [private]
 

Modifiers of the most recent declaration.

Class CCM::CSharpParser::stubDeclClass [private]
 

Particular stub class if currDeclType == stubType.

Type CCM::CSharpParser::stubType = ( new Class("", null, "" ) ).GetType() [static, private]
 

Stub type constant for easier comparisons.

short [] CCM::CSharpParser::yyCheck [static, protected]
 

short [] CCM::CSharpParser::yyDefRed [static, private]
 

short [] CCM::CSharpParser::yyDgoto [static, protected]
 

Initial value:

{ 4, 5, 6, 7, 8, 9, 121, 10, 11, 85, 12, 13, 14, 61, 124, 122, 204, 205, 50, 480, 145, 146, 147, 148, 211, 318, 212, 276, 277, 86, 87, 88, 223, 90, 91, 92, 93, 94, 95, 96, 97, 151, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 224, 225, 226, 112, 113, 213, 228, 383, 323, 272, 273, 274, 432, 354, 355, 322, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 411, 397, 452, 430, 476, 487, 453, 454, 377, 378, 379, 380, 381, 441, 442, 443, 459, 460, 382, 326, 327, 289, 290, 41, 386, 387, 388, 389, 422, 423, 15, 126, 269, 207, 127, 291, 292, 293, 294, 295, 42, 43, 296, 16, 17, 22, 23, 57, 48, 114, 115, 116, 117, 118, 119, }

int CCM::CSharpParser::yyFinal = 4 [static, protected]
 

debugging support, requires the package jay.yydebug.

Set to null to suppress debugging messages.

short [] CCM::CSharpParser::yyGindex [static, protected]
 

Initial value:

{ 0, 0, 413, 414, -36, -94, 0, 0, 0, -2, 0, 0, -222, 0, 162, 0, 0, 0, 159, 0, -166, -67, 0, 0, -268, 89, 284, 0, 0, 0, -62, 0, -11, -243, 0, -185, 82, 0, 0, 800, 0, 0, 107, 147, -78, -7, 3, 4, 246, 249, 245, 248, 247, 0, 0, 149, 167, 0, 164, 161, 0, 0, 243, 0, 0, -142, 0, -291, 0, -274, 0, 0, 0, -314, 0, -231, 0, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -394, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -24, 0, 0, 0, 0, 0, 0, 0, 23, 0, 0, 0, 80, 68, 0, 0, 177, 77, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 176, 0, 0, 0, 428, 0, 0, 456, 0, 425, 0, 0, 0, 0, 0, 275, 277, 279, }

short [] CCM::CSharpParser::yyLen [static, private]
 

short [] CCM::CSharpParser::yyLhs [static, private]
 

int CCM::CSharpParser::yyMax [protected]
 

initial size and increment of the state/value stack [default 256].

This is not final so that it can be overwritten outside of invocations of yyparse().

string [] CCM::CSharpParser::yyNames [static, protected]
 

short [] CCM::CSharpParser::yyRindex [static, protected]
 

short [] CCM::CSharpParser::yySindex [static, protected]
 

short [] CCM::CSharpParser::yyTable [static, protected]
 


The documentation for this class was generated from the following file:
Generated on Mon Jun 21 01:20:50 2004 for cs2ccmb by doxygen 1.3.7