xseagullx / antlrv4_groovy_grammar Goto Github PK
View Code? Open in Web Editor NEWGoogle Summer of Code project
Google Summer of Code project
I can get two versions of AST. First is old AST, second - new one wich I obtain via new Antlrv4 - based parser.
I need some easy way to test their equality.
There are different approaches, but at this point I think writing AST comparator, overloading equals method for it would be the best.
Allow to constructions like a() {}
Also allow parenthesisless calls, and no coma, between closures as argument.
If constructor is declared with no modifiers we create correct AST node.
If there is visibility modifier there - We threat it like ordinary method.
class A {
A(){} // ConstructorNode
public A(){} // MethodNode
}
Implement inner classes.
Implement anonymous classes.
Allow modifiers to class declaration.
new Expression for classes and arrays.
Yes to multidimensional arrays.
No for anonymous classes.
Allow [] in type declaration.
Should recognize numeric/string literals, null
.
No need to support GStrings/ escapes and so on.
I need to implement GStrings.
After Splitting Grammar in #39 it will be possible to do with lexer modes.
generic class params, method params. Use of generic in method declaration and extends/implements clause.
If class was imported, short class name should lead to creation of ClassNode with full-qualified name.
Minimal functionality
def a = [1,2,3] // list
def b = [text1: 1,text2: 2,(text3): 3] // map.
def c = [:] | [] // empty ones
Now constructor annotation conflicts with semantic predicate. Now it's annotation possibility will mess code a lot. After some cleanup #32 it will be simple task.
Code like that private def <T> T a() {
will lead to invalid parsing as def T is typeDeclaration and generic parameters list is between them.
Allow annotated language elements.
Annotations may be used as modifiers in any declaration, whether package (§7.4.1), class (§8.1.1) (including enums (§8.9)), interface (§9.1.1) (including annotation types (§9.6)), field (§8.3.1, §9.3), method (§8.4.3, §9.4), formal parameter (§8.4.1), constructor (§8.8.3), or local variable (§14.4.1).
Annotations may also be used on enum constants. Such annotations are placed immediately before the enum constant they annotate.
Support MarkerAnnotations and Single-value ones.
No need to implement annotation interface declaration.
Allow declaring members in classes.
Support modifiers and type declarations.
In following snippet, methods and fields are treated as constructor.
class A {
public publicProperty // Field
String stringProperty // Treated as constructor!
int getValue() {} // Treated as constructor!
void setValue(int value) {} // Treated as constructor!
}
It's the best place for testing statements and expressions, so it should be implemented first.
Smth like 23 * 12 + 2 || '23' + !23 && 4 + 2 / 2 - 3 || 23
may be used for testing.
{Args -> }
notation.
There is lack of default clause in current argumentDeclarationList implementation.
Due to ambiguity while working on #37, unary +
and unary -
expressions was disabled.
'a + b' code became command Expression this.a(+b)
.
Remove order-dependency in comparison.
Support for statements outside any groovy class.
Antlr grammar can be organized in two ways, combined grammar or different lexer and parser grammars. We need to use second aproach to make Lexer modes work.
Make correct implicitThis handling, and start work on Groovy'sh method calls.
I.e:
println "hello"
method argument method2 argument2 method3 {closureCode}
Now in declaration, smth like def def method() {}
is possible. Should throw unexpected token exception.
Code like that:
class A {
def member() {}
}
will produce error:
line 2:0 extraneous input 'def' expecting {'}', ';', VISIBILITY_MODIFIER, KW_ABSTRACT, KW_STATIC, KW_FINAL, KW_TRANSIENT, KW_NATIVE, KW_VOLATILE, KW_SYNCHRONIZED, NL, IDENTIFIER}
Empty string constant is handled incorrectly. It became ''
because of invalid substring operation.
Implement +=, -=, *= and so on.
I need to implement correct properties node creation.
Properties are being creating for public fields and, maybe for accessor methods.
See
Property and field rules
When Groovy is compiled to bytecode, the following rules are used.
If the name is declared with an access modifier (public, private or protected) then a field is generated.
A name declared with no access modifier generates a private field with public getter and setter (i.e. a property).
If a property is declared final the private field is created final and no setter is generated.
You can declare a property and also declare your own getter or setter.
You can declare a property and a field of the same name, the property will use that field then.
If you want a private or protected property you have to provide your own getter and setter which must be declared private or protected.
If you access a property from within the class the property is defined in at compile time with implicit or explicit this (for example this.foo, or simply foo), Groovy will access the field directly instead of going though the getter and setter.
If you access a property that does not exist using the explicit or implicit foo, then Groovy will access the property through the meta class, which may fail at runtime.
Static and per-instance initializers.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.