Book Image

Groovy for Domain-Specific Languages, Second Edition

By : Fergal Dearle
Book Image

Groovy for Domain-Specific Languages, Second Edition

By: Fergal Dearle

Overview of this book

Table of Contents (20 chapters)
Groovy for Domain-specific Languages Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
1
Introduction to DSLs and Groovy
Index

Index

A

  • acceptance test-driven development (ATDD) / Spock as a DSL
  • Apache Antlr
    • URL / Compiler phases
  • assert keyword
    • about / Assertions
  • association relationships
    • about / Associations
    • one-to-one association / One-to-one
    • constraints / Constraints
    • one-to-many association / One-to-many
    • many-to-many associations / Many-to-many
  • AST
    • about / What is an AST
    • compiler phases / Compiler phases
  • ASTBuilder
    • about / Using ASTBuilder
    • using / Using ASTBuilder
    • build from code / Build from code
    • build from Spec / Build from Spec
    • traits to rescue / Traits to the rescue
  • ast package
    • reference / What is an AST
  • autoboxing
    • about / Autoboxing

B

  • basic concepts, Gradle
    • Gradle build scripts / Gradle build scripts
    • Gradle tasks / Gradle tasks
    • dependencies / Dependencies
  • behavior-driven development (BDD) / Spock as a DSL
  • behavior-driven development (BDD) tool
    • about / Spock tests
  • binding
    • about / Groovy bindings
  • bindings, exploiting in DSLs
    • about / Exploiting bindings in DSLs
    • closures, as built-in methods / Closures as built-in methods
    • closures, as repeatable blocks / Closures as repeatable blocks
    • specification parameter, using / Using a specification parameter
    • closures, as singleton blocks / Closures as singleton blocks
    • binding properties, using to form context / Using binding properties to form context
    • results, storing / Storing and communicating results
    • results, communicating / Storing and communicating results
  • blocks
    • about / Blocks
  • boilerplate
    • removing / Removing the boilerplate
  • builder code structure
    • about / The builder code structure
    • closure method calls / The builder code structure, Closure method calls
    • closure method resolution / The builder code structure
    • pretended methods / The builder code structure, Pretended methods
    • named parameters / The builder code structure
    • closure delegate / The builder code structure, The closure delegate
    • resolve strategy / The resolve strategy – OWNER_FIRST
  • builders
    • about / Builders
    • builder design pattern / The builder design pattern
    • Groovy builders, using / Using Groovy builders
    • MarkupBuilder / MarkupBuilder, Builders for every occasion
    • namespaced XML / Namespaced XML
    • GroovyMarkup syntax / The GroovyMarkup syntax
    • program logic, using with / Using program logic with builders
    • NodeBuilder / Builders for every occasion, NodeBuilder
    • DOMBuilder / Builders for every occasion
    • SAXBuilder / Builders for every occasion
    • JMXBuilder / Builders for every occasion
    • SwingBuilder / Builders for every occasion
    • working / How builders work
  • BuilderSupport
    • about / BuilderSupport
    • hook methods / BuilderSupport hook methods
    • database builder / A database builder
  • built-in methods
    • adding / Adding built-in methods
  • built-in tasks, Gradle tasks
    • about / Built-in tasks and plugins
    • tasks / Built-in tasks and plugins
    • wrapper / Built-in tasks and plugins
    • projects / Built-in tasks and plugins
    • dependencies / Built-in tasks and plugins

C

  • closure parameters
    • about / Closure parameters
    • zero parameters, enforcing / Enforcing zero parameters
    • doCall method / Parameters and the doCall method
    • multiple parameters, passing / Passing multiple parameters
    • default parameter values / Default parameter values
    • closure, implementing in Java / Implementing closures in Java
    • curried parameters / Curried parameters
  • closure return values
    • about / Closure return values
  • closures / Groovy improvements
  • closures, as method parameters
    • about / Closures as method parameters
    • method parameters, as DSL / Method parameters as DSL
    • parameters, forwarding / Forwarding parameters
  • closures, Groovy
    • about / Closures, What is a closure?
    • operator overloading / Groovy operator overloading
    • regular expression support / Regular expression support
    • optional syntax / Optional syntax
    • markup / Groovy markup
    • collection methods / Closures and collection methods
    • calling / Calling closures
    • implicit doCall method / The implicit doCall method
  • closure scope
    • about / The closure scope
    • this variable / The this, owner, and delegate variables
    • owner variable / The this, owner, and delegate variables
    • delegate variable / The this, owner, and delegate variables
    • closure composition / Closure composition
    • closure trampoline / Closure trampoline
    • closure memoization / Closure memoization
  • Cloud9
    • URL / A game DSL – goals
  • Codehaus
    • URL / How to find and install Groovy from binaries
  • CoderDojo
    • URL / Groovy as a teaching language
  • collections
    • about / Collections
    • ranges / Ranges
    • lists / Lists
    • maps / Maps
  • command-line interface
    • adding / Adding a command-line interface
  • command chains
    • about / Command chains
  • CompilationConfiguration object
    • reference / Adding built-in methods
  • compiler phases, AST
    • about / Compiler phases
    • initialization / Compiler phases
    • parsing / Compiler phases
    • conversion / Compiler phases
    • semantic analysis / Compiler phases
    • canonicalization / Compiler phases
    • instruction selection / Compiler phases
    • class generation / Compiler phases
    • output / Compiler phases
    • finalization / Compiler phases
  • composition relationship
    • about / Composition
  • Computer Products Inc. (CPI) / A DSL for process engineers
  • control structures
    • about / Control structures
    • Groovy Truth / Groovy Truth
    • ternary operator / Ternary and Elvis operators
    • Elvis operator / Ternary and Elvis operators
    • spaceship operator / Spaceship and Elvis operators
    • switch statement / The switch statement
    • loops / Loops
  • cURL
    • about / Working with the Twitter APIs
    • URL / Working with the Twitter APIs
  • curried closures
    • about / Curried parameters
  • curried parameters
    • about / Curried parameters
  • currying
    • about / Curried parameters
  • Cygwin
    • URL / Installing GVM on Windows
    • about / Installing GVM on Windows

D

  • document type definition (DTD)
    • about / DSL – a new name for an old idea
  • domain-specific language (DSL)
    • about / DSL – a new name for an old idea
    • evolution of programming languages / The evolution of programming languages
    • language-oriented programming / Language-oriented programming
    • users / Who are DSLs for?
    • for process engineers / A DSL for process engineers
    • stakeholder participation / Stakeholder participation
    • design / DSL design and implementation
    • implementation / DSL design and implementation
    • external, versus internal DSL / External versus internal DSLs
    • operator overloading / Operator overloading
  • domaInternational Obfuscated C Code Contest (IOCCC)
    • about / The evolution of programming languages
    • URL / The evolution of programming languages
  • DSL, designing
    • BroadbandPlus / BroadbandPlus
    • reward types / Reward types
    • reward DSL / The reward DSL
    • events, handling / Handling events – deferred execution
    • deferred execution / Handling events – deferred execution
    • convenience methods / Convenience methods and shorthand
    • shorthand features / Convenience methods and shorthand
    • offers / The offers
    • RewardService class / The RewardService class
    • BroadbandPlus application classes / The BroadbandPlus application classes
    • testing, with Spock / Testing with Spock
  • dynamic finders
    • about / Dynamic finders

E

  • Eclipse plugin
    • about / The Eclipse plugin
  • Emacs
    • URL / Other IDEs and editors
  • Enterprise Java Beans (EJB)
    • about / DSL – a new name for an old idea
  • ExpandoMetaClass
    • about / ExpandoMetaClasses
    • methods, replacing / Replacing methods
    • static methods, adding / Adding or overriding static methods
    • static methods, overriding / Adding or overriding static methods
    • dynamic method naming / Dynamic method naming
    • overloaded methods, adding / Adding overloaded methods
    • constructors, adding / Adding constructors
  • EXTended Operations Language (EXTOL) / A DSL for process engineers

F

  • FactoryBuilderSupport
    • about / FactoryBuilderSupport
    • newInstance / FactoryBuilderSupport
    • onHandleNodeAttributes / FactoryBuilderSupport
    • setParent / FactoryBuilderSupport
    • setChild / FactoryBuilderSupport
    • isLeaf / FactoryBuilderSupport
    • onNodeCompleted / FactoryBuilderSupport
  • feature methods
    • about / Feature methods
  • fields
    • about / Fields
  • fixture blocks
    • about / Fixture blocks
  • fixture methods
    • about / Fixture methods
    • setupSpec() / Fixture methods
    • cleanupSpec() / Fixture methods
    • setup() / Fixture methods
    • cleanup() / Fixture methods

G

  • 4GL (fourth generation language) / Spreadsheets and 4GLs
  • @Grab annotation
    • URL / Using Twitter4J Java APIs
  • game DSL
    • for kids / A game DSL for kids
    • goals / A game DSL – goals
    • architecture / Architecture and technology choices
    • technology / Architecture and technology choices
    • TicTacToe / TicTacToe in a DSL
    • AST transform, implementing / Implementing the AST transform
    • game engine pattern, building / Building the game engine pattern
    • DSL, testing / Testing the DSL
    • class loading issues / Class loading issues
    • Gradle subprojects / Gradle subprojects
    • debugging / Debugging
    • game server / The game server
    • Spring Boot server, implementing / Integrating with Spring Boot server
    • controller annotations / Controller annotations
    • JSONP / JSONP
    • DSL, loading / Loading the DSL
    • Spring Data mapping, for MongoDB / Spring Data mapping for MongoDB
    • game UI / The Game UI
  • GeeTwitter class
    • fleshing out / Fleshing out GeeTwitter
  • global AST transformations
    • about / Global AST transformations
    • finite state machine DSL / A finite state machine DSL
    • state machine pattern / The state machine pattern
    • state machine AST transformation / A state machine AST transformation
    • StateMachineASTTransformation / A state machine AST transformation
    • StateMachineParser / A state machine AST transformation
    • StateMachineModel / A state machine AST transformation
    • StateMachineBuilder / A state machine AST transformation
    • errors, handling / Handling errors – compile errors
    • compile error / Handling errors – compile errors
    • AST nodes, building / Building the new AST nodes
    • state machine DSL, testing / Testing the state machine DSL
    • packaging / Compiling and packaging an AST transformation
    • compiling / Compiling and packaging an AST transformation
  • GORM
    • about / Grails object relational mapping – GORM
    • Grails quick start / Grails quick start
    • grails-app directory / The grails-app directory
    • URL / The grails-app directory
    • relationships, modeling / Modeling relationships
    • querying / Querying
  • GORM model
    • building / Building a GORM model
    • domain classes, using / Using domain classes
  • Gradle
    • installing / Installing Gradle
    • reference, for installation packages / Installing Gradle
    • basic concepts / Gradle basics
    • testing, Spock used / Testing Gradle using Spock
  • Gradle build scripts
    • about / Gradle basics, Gradle build scripts
  • Gradle DSL
    • URL / Further reading
  • Gradle Groovy plugin
    • about / The Gradle Groovy plugin
  • Gradle projects
    • about / Gradle basics
  • Gradle tasks
    • about / Gradle basics, Gradle tasks
    • actions, adding / Adding actions to tasks
    • default tasks / Default tasks
    • task dependencies, creating / Creating task dependencies
    • built-in tasks / Built-in tasks and plugins
    • plugins / Plugins
    • repositories / Repositories
  • Grails
    • download link / Finding a named closure field
    • reference / GORM as a DSL
  • grails-app directory
    • about / The grails-app directory
    • grails-app/conf / The grails-app directory
    • grails-app/controllers / The grails-app directory
    • grails-app/domain / The grails-app directory
    • grails-app/services / The grails-app directory
    • grails-app/view / The grails-app directory
  • grails command / Building a GORM model
  • Grails object relational mapping
    • GORM / Grails object relational mapping – GORM
  • Groovy
    • about / Groovy
    • compatible, with JVM / A natural fit with the JVM
    • language features / Groovy language features
    • closures / Closures
    • installing, with GVM / Installing Groovy with GVM
    • installing, from libraries / How to find and install Groovy from binaries
    • download link / How to find and install Groovy from binaries
    • running / Running Groovy
  • Groovy, as teaching language
    • about / Groovy as a teaching language
    • complexity, hiding / Hiding complexity
  • GroovyBeans
    • about / Properties and GroovyBeans
  • Groovy bindings
    • about / Groovy bindings
    • exploiting, in DSLs / Exploiting bindings in DSLs
  • groovyc command
    • about / The Groovy compiler – groovyc
  • Groovy compiler
    • about / The Groovy compiler – groovyc
  • Groovy console
    • about / The Groovy console – groovyConsole
  • groovyConsole
    • about / The Groovy console – groovyConsole
  • Groovy Eclipse
    • about / Eclipse
    • URL / Eclipse
  • Groovy IDE
    • about / The Groovy IDE and editor integration
    • NetBeans / NetBeans
    • Eclipse / Eclipse
    • Spring STS / Spring STS
    • IntelliJ IDEA / IntelliJ IDEA
  • Groovy improvements
    • about / Groovy improvements
    • friends, finding / A Groovier way to find friends
  • Groovy language
    • about / Introducing the Groovy language
    • module structure / The module structure
    • shorthand features / Groovy shorthand
    • assertions / Assertions
    • autoboxing / Autoboxing
    • strings / Strings
    • regular expressions / Regular expressions
    • methods / Methods and closures
    • closures / Methods and closures
    • control structures / Control structures
    • collections / Collections
    • operators / Operators
  • Groovy language features
    • about / Groovy language features
    • static and optional typing / Static and optional typing
    • native support, for lists and maps / Native support for lists and maps
  • GroovyMarkup
    • about / The GroovyMarkup syntax
    • and HTML / GroovyMarkup and HTML
  • Groovy Script class
    • reference / Adding built-in methods
  • Groovy script engine
    • about / The Groovy script engine – groovy
  • Groovy searching
    • about / Groovy searching
  • Groovy Server Pages (GSPs) / The grails-app directory
  • groovysh command
    • about / The Groovy shell – groovysh
  • Groovy shell
    • about / The Groovy shell – groovysh
  • GVM
    • about / Installing Groovy with GVM
    • URL / Installing Groovy with GVM
    • installing / Installing GVM
    • installing, on Windows / Installing GVM on Windows

H

  • Hello World program
    • about / The Groovy script engine – groovy
  • helper methods
    • about / Helper methods
  • hook methods, BuilderSupport
    • createNode method / A database builder
    • setParent hook / A database builder
    • nodeCompleted hook / A database builder

I

  • IDEA plugin
    • about / The IDEA plugin
  • implicit doCall method
    • about / The implicit doCall method
  • Independent Software Vendors (ISVs) / A database builder
  • inheritance, relationships
    • about / Inheritance
    • mapping / Mapping
  • IntelliJ IDEA
    • about / IntelliJ IDEA

J

  • Java Management Extensions (JMX) / Builders for every occasion
  • JDeveloper
    • about / Other IDEs and editors
  • JEdit
    • about / Other IDEs and editors
  • JSONP mechanism
    • URL / JSONP
  • JUnit
    • about / JUnit

L

  • local AST transformations
    • about / Local AST transformations
    • implementing / Local AST transformations

M

  • many-to-many association / Many-to-many
  • MarkupBuilder
    • about / MarkupBuilder
  • meta-programming
    • about / Metaprogramming and the Groovy MOP
  • Meta Object Protocol (MOP) / Using Groovy builders
    • about / Metaprogramming and the Groovy MOP
    • reflection / Reflection
    • Groovy reflection shortcuts / Groovy reflection shortcuts
    • Expando / Expandos
    • categories / Categories
    • traits / Traits
    • MetaClass / MetaClass
    • MetaClass.invokeMethod / Pretended methods – MetaClass.invokeMethod
    • this keyword / Understanding this, delegate, and owner
    • owner keyword / Understanding this, delegate, and owner
    • delegate keyword / Understanding this, delegate, and owner
  • methodMissing / methodMissing
  • method pointers
    • about / Method pointers
  • Model View Controller (MVC) / The builder design pattern, The grails-app directory

N

  • named closure field
    • finding / Finding a named closure field
  • named parameters
    • about / Properties and GroovyBeans, Named parameters
    • in DSLs / Named parameters in DSLs
  • Napkin Look and Feel line
    • about / SwingBuilder
  • NetBeans
    • about / NetBeans
    • URL / NetBeans
  • NodeBuilder
    • about / NodeBuilder
    • GPath, used for navigating node tree / Using GPath to navigate a node tree
  • null safe dereference operator
    • about / Null safe dereference

O

  • one-to-many association / One-to-many
  • one-to-one association / One-to-one
  • operators
    • about / Operators
    • spread / Spread and spread-dot
    • spread-dot / Spread and spread-dot
    • null safe dereference operator / Null safe dereference
    • operator overloading / Operator overloading

P

  • plugins, Gradle tasks
    • about / Plugins
    • Gradle Groovy plugin / The Gradle Groovy plugin
    • IDEA plugin / The IDEA plugin
    • Eclipse plugin / The Eclipse plugin
  • POGO (plain old Groovy object)
    • about / Properties and GroovyBeans
  • PoorMansTagBuilder class / invokeMethod
  • pretended methods
    • about / Pretended methods
    • invokeMethod / invokeMethod
    • methodMissing / methodMissing
  • programming languages
    • evolution / The evolution of programming languages
    • general-purpose languages / General-purpose languages
    • 4GL (fourth generation language) / Spreadsheets and 4GLs

Q

  • querying, GORM
    • about / Querying
    • dynamic finders / Dynamic finders
    • GORM, as DSL / GORM as a DSL

R

  • range of values
    • defining / Ranges
  • refactoring
    • about / Refactoring
  • regex find operator
    • about / Regular expressions
  • regex match operator
    • about / Regular expressions
  • regex pattern operator
    • about / Regular expressions
  • relationships
    • about / Modeling relationships
    • associations / Modeling relationships, Associations
    • composition / Modeling relationships, Composition
    • inheritance / Modeling relationships, Inheritance
  • resolve strategy / The resolve strategy – OWNER_FIRST
  • rewards DSL
    • building / Building a rewards DSL
    • DSL, designing / Designing the DSL
  • RVM (Ruby Version Manager) / Installing Groovy with GVM

S

  • Scratch
    • URL / Hiding complexity
  • search
    • improving / Improving search
  • shebang scripts
    • about / Shebang scripts
  • shorthand features, Groovy language
    • about / Groovy shorthand
    • implicit imports / Implicit imports
    • default visibility / Default visibility, optional semicolon
    • optional semicolon / Default visibility, optional semicolon
    • optional parentheses / Optional parentheses
    • optional dot in method chains / The optional dot in method chains
    • dynamic types / Dynamic types
    • optional return keyword / The optional return keyword
    • properties / Properties and GroovyBeans
    • GroovyBeans / Properties and GroovyBeans
  • single page app (SPI) / Architecture and technology choices
  • Spock
    • about / Spock tests, Spock
    • used, for testing Gradle / Testing Gradle using Spock
    • URL / Further reading
    • as DSL / Spock as a DSL
    • fixture methods / Spock
    • feature method / Spock
    • blocks / Spock
    • helper methods / Spock
    • JUnit / JUnit
    • reference / JUnit
  • Spock specification structure
    • about / Spock specification structure
    • feature methods / Spock specification structure, Feature methods
    • blocks / Spock specification structure, Blocks
    • fields / Spock specification structure, Fields
    • fixture methods / Spock specification structure, Fixture methods
    • helper methods / Spock specification structure, Helper methods
  • Spock tests
    • about / Spock tests
    • given / Given, when, then
    • when / Given, when, then
    • then / Given, when, then
    • where blocks / Where blocks
    • fixture blocks / Fixture blocks
  • spread-dot operator
    • about / Spread and spread-dot
  • spread operator
    • about / Spread and spread-dot
  • Spring STS
    • about / Spring STS
    • URL / Spring STS
  • state machine DSL
    • states / A state machine AST transformation
    • events / A state machine AST transformation
    • transitions / A state machine AST transformation
  • strategies, builders
    • OWNER_FIRST / How builders work
    • DELEGATE_FIRST / How builders work
    • OWNER_ONLY / How builders work
    • DELEGATE_ONLY / How builders work
  • SwingBuilder
    • about / SwingBuilder

T

  • test-driven development (TDD) / Spock as a DSL
  • TextMate
    • about / Other IDEs and editors
  • third generation language (3GL) / Spreadsheets and 4GLs
  • Twitter
    • about / Twitter
    • URL / Working with the Twitter APIs
  • Twitter4J
    • URL / Using Twitter4J Java APIs
  • Twitter4J Java APIs
    • using / Using Twitter4J Java APIs
    • tweeting / Tweeting
    • direct message / Direct messages
    • searching / Searching
    • following / Following
  • Twitter APIs
    • working with / Working with the Twitter APIs
    • URL / Working with the Twitter APIs

U

  • UltraEdit
    • about / Other IDEs and editors

V

  • virtual machine (VM)
    • about / Groovy

W

  • where blocks
    • about / Where blocks
  • Windows Installer
    • URL / How to find and install Groovy from binaries