diff --git a/src/scanner.l b/src/scanner.l index 9ff082d475c..632c8a51247 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -6198,6 +6198,14 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) } } "{" { curlyCount++; } +"}"{B}*"=" { + // fall back to next rule if it's not the right bracket + if (curlyCount != 0) REJECT; + current->initializer = "="; + current->endBodyLine=yyLineNr; + lastInitializerContext = FindMembers; + BEGIN(ReadInitializer); + } "}" { if (curlyCount) { @@ -6207,6 +6215,8 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP}) { mtype = Method; virt = Normal; + // not really important, but while we are at it + current->endBodyLine=yyLineNr; unput(';'); BEGIN(FindMembers); } diff --git a/testing/066/class_class1.xml b/testing/066/class_class1.xml new file mode 100644 index 00000000000..008bcc695e2 --- /dev/null +++ b/testing/066/class_class1.xml @@ -0,0 +1,50 @@ + + + + Class1 + + + int + int Class1.Property1 + + Property1 + = 1 + + + + + + + + + + string + string Class1.Property2 + + Property2 + + + + + + + + + + + + + + + + + Class1 + Property1 + + + Class1 + Property2 + + + + diff --git a/testing/066_property_initializer.cs b/testing/066_property_initializer.cs new file mode 100644 index 00000000000..d5b5c59b989 --- /dev/null +++ b/testing/066_property_initializer.cs @@ -0,0 +1,7 @@ +// objective: C# property initializer +// check: class_class1.xml +class Class1 +{ + public int Property1 { get; } = 1; + public string Property2 { get; set; } +}