Code Monkey home page Code Monkey logo

antlrv4_groovy_grammar's People

Contributors

xseagullx avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

shiva10162

antlrv4_groovy_grammar's Issues

Get quick and reliable way to compare produced AST.

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.

Closures after parenthesis.

Allow to constructions like a() {}
Also allow parenthesisless calls, and no coma, between closures as argument.

"new" expression

new Expression for classes and arrays.
Yes to multidimensional arrays.
No for anonymous classes.

Arrays.

Allow [] in type declaration.

GStrings-related magic.

I need to implement GStrings.

After Splitting Grammar in #39 it will be possible to do with lexer modes.

Generics

generic class params, method params. Use of generic in method declaration and extends/implements clause.

List/table constructors.

Minimal functionality

  • list
  • map with ordinary string fields //(short notation without ' or " )
  • map with variable - based keys // in parentheses()
def a = [1,2,3] // list 
def b = [text1: 1,text2: 2,(text3): 3] // map. 
def c = [:] | [] // empty ones

Allow annotate constructors.

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.

Generics doesn't allow def keyword

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.

Basic support for anntoations

  • Make a quick look at specifications, to get minimal list of requirements.
  • Implement it.

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.

Invalid method/constructor recognition.

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!
}

Implement method bodies.

It's the best place for testing statements and expressions, so it should be implemented first.

More constantsExpressions.

  1. Boolean ones, true/false.
  2. slashy and double quoted strings
  3. Multiline strings
  4. Floating-point literals.

Script support.

Support for statements outside any groovy class.

! comment

Split the grammar.

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.

Field access and method calls.

Make correct implicitThis handling, and start work on Groovy'sh method calls.

I.e:

  • Allow to loose parenthesis like println "hello"
  • Allow closure after parenthesis.
  • Allow map constructor for parameters.
  • Support control expressions like method argument method2 argument2 method3 {closureCode}

Method with def type specifier is lead to parser error.

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}

Refactoring

  • Refactor tests.
  • Refactor AST builder.
  • Refactor AST comparator.

Properties in classes.

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.