Skip to content

Commit

Permalink
a bunch of fixes to the grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
yole committed Jun 8, 2015
1 parent 5f0171a commit 18753a1
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 18 deletions.
3 changes: 1 addition & 2 deletions grammar/src/class.grm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal class Example<X, T : Comparable<X>>(protected val x : Foo<X, T>, y : So
*/

class
: modifiers ("class" | "trait") SimpleName
: modifiers ("class" | "interface") SimpleName
typeParameters?
primaryConstructor?
(":" annotations delegationSpecifier{","})?
Expand Down Expand Up @@ -63,7 +63,6 @@ typeConstraints

typeConstraint
: annotations SimpleName ":" type
: annotations "class" "object" SimpleName ":" type
;
/**
See [Generic constraints](generics.html#generic-constraints)
Expand Down
3 changes: 1 addition & 2 deletions grammar/src/class_members.grm
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ memberDeclaration

anonymousInitializer
: "init" block
: block
;

companionObject
: modifiers "class" object
: modifiers "companion" "object"
;

valueParameters
Expand Down
2 changes: 1 addition & 1 deletion grammar/src/control.grm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ loop
;

for
: "for" "(" annotations ("val" | "var")? (multipleVariableDeclarations | variableDeclarationEntry) "in" expression ")" expression
: "for" "(" annotations (multipleVariableDeclarations | variableDeclarationEntry) "in" expression ")" expression
;

while
Expand Down
2 changes: 1 addition & 1 deletion grammar/src/enum.grm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ See [Enum classes](enum-classes.html)
*/

enumClassBody
: "{" enumEntries members "}"
: "{" enumEntries (";" members)? "}"
;

enumEntries
Expand Down
3 changes: 2 additions & 1 deletion grammar/src/expressions.grm
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ declaration
: function
: property
: class
: typeAlias
// : typeAlias
: object
;

Expand Down Expand Up @@ -289,3 +289,4 @@ objectLiteralMember
factoryMethod
: accessModifier? SimpleName typeParameters? functionParameters functionBody
;
*/
9 changes: 1 addition & 8 deletions grammar/src/modifiers.grm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ modifierKeyword
: accessModifier
: varianceAnnotation
: memberModifier
: parameterKind
: annotations
;

Expand All @@ -24,7 +23,7 @@ classModifier
: "final"
: "enum"
: "open"
: "attribute"
: "annotation"
;

memberModifier
Expand All @@ -45,9 +44,3 @@ varianceAnnotation
: "in"
: "out"
;

parameterKind
: "lazy"
: "out"
: "ref"
;
4 changes: 3 additions & 1 deletion grammar/src/toplevel.grm
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ toplevelObject
: object
: function
: property
: typeAlias
// : typeAlias
;

package
Expand All @@ -59,6 +59,8 @@ package
See [Packages](packages.html)
*/

/*
typeAlias
: modifiers "typealias" SimpleName (typeParameters typeConstraints)? "=" type
;
*/
4 changes: 3 additions & 1 deletion grammar/src/types.grm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type
// IF YOU CHANGE THIS, please, update TYPE_FIRST in JetParsing
typeDescriptor
: "(" typeDescriptor ")"
: selfType
// : selfType
: functionType
: userType
: nullableType
Expand All @@ -29,9 +29,11 @@ typeDescriptor
nullableType
: typeDescriptor "?"

/*
selfType
: "This"
;
*/

userType
: ("package" ".")? simpleUserType{"."}
Expand Down
2 changes: 1 addition & 1 deletion grammar/src/when.grm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ See [When-expression](control-flow.html#when-expression)
*/

when
: "when" ("(" (modifiers "val" SimpleName "=")? expression ")")? "{"
: "when" ("(" expression ")")? "{"
whenEntry*
"}"
;
Expand Down

0 comments on commit 18753a1

Please sign in to comment.