M
MBR
Hello... I'm using the grammar at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csspec/html/vclrfcsharpspec_c.asp
as a reference in creating my own C# parser using a custom framework.
(Please let me know if there's a better group to post in.)
Some questions:
(1) Is this grammar specification known to be complete and correct?
(2) Is there a normalized LL grammar available already suited for
(backtracking) recursive decent systems?
(3) Much of the grammar can be simplified by using EBNF-style
specifications -- it would be nice to find one this way already
(5) Is there a "parameterized" version that allows for c# 2.0 and c# 3.0,
with and without managed extensions?
(6) Are there alternate sources? (I've found some incomplete grammars and
some that are already re-purposed to the point of being unreadable.)
(7) There are simple and some not so simple left-recursions in the grammar.
The simple, direct recursions can be changed to EBNF-style repetitions
without left recursion:
multiplicative-expression:
unary-expression
multiplicative-expression * unary-expression
multiplicative-expression / unary-expression
multiplicative-expression % unary-expression
becomes (I think):
multiplicative_expression ::=
(unary_expression, "*" )* , unary_expression |
(unary_expression, "/" )* , unary_expression |
(unary_expression, "%" )* , unary_expression.
But there are also some very deep recursions such as this one (of many that
can be detected):
type -->
| reference_type -->
| | array_type -->
| | | non_array_type -->
< < < < type <-- Recursive
I'm wondering if this is necessary or even correct. Unlike the direct
recursions, in some of these cases it's hard to tell what's "meant" making
re-writes difficult.
Any pointers/advice appreciated...
thanks,
mike
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csspec/html/vclrfcsharpspec_c.asp
as a reference in creating my own C# parser using a custom framework.
(Please let me know if there's a better group to post in.)
Some questions:
(1) Is this grammar specification known to be complete and correct?
(2) Is there a normalized LL grammar available already suited for
(backtracking) recursive decent systems?
(3) Much of the grammar can be simplified by using EBNF-style
specifications -- it would be nice to find one this way already
(5) Is there a "parameterized" version that allows for c# 2.0 and c# 3.0,
with and without managed extensions?
(6) Are there alternate sources? (I've found some incomplete grammars and
some that are already re-purposed to the point of being unreadable.)
(7) There are simple and some not so simple left-recursions in the grammar.
The simple, direct recursions can be changed to EBNF-style repetitions
without left recursion:
multiplicative-expression:
unary-expression
multiplicative-expression * unary-expression
multiplicative-expression / unary-expression
multiplicative-expression % unary-expression
becomes (I think):
multiplicative_expression ::=
(unary_expression, "*" )* , unary_expression |
(unary_expression, "/" )* , unary_expression |
(unary_expression, "%" )* , unary_expression.
But there are also some very deep recursions such as this one (of many that
can be detected):
type -->
| reference_type -->
| | array_type -->
| | | non_array_type -->
< < < < type <-- Recursive
I'm wondering if this is necessary or even correct. Unlike the direct
recursions, in some of these cases it's hard to tell what's "meant" making
re-writes difficult.
Any pointers/advice appreciated...
thanks,
mike