From c8603e6d317bcf18600593f545e3e4e72948d91c Mon Sep 17 00:00:00 2001 From: Chengyuan Zhang Date: Thu, 6 May 2021 01:17:25 -0700 Subject: [PATCH 1/2] Use Gradle 7.0 --- examples/gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gradle/wrapper/gradle-wrapper.properties b/examples/gradle/wrapper/gradle-wrapper.properties index 4d9ca164914..f371643eed7 100644 --- a/examples/gradle/wrapper/gradle-wrapper.properties +++ b/examples/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 493c71e36fcfd5e23b4217f513b78580b81affa3 Mon Sep 17 00:00:00 2001 From: Chengyuan Zhang Date: Thu, 6 May 2021 01:18:20 -0700 Subject: [PATCH 2/2] Add dummy scala and antlr sources to test IDE behavior. --- examples/build.gradle | 28 +++++++++------ examples/src/main/antlr/Chat.g4 | 56 ++++++++++++++++++++++++++++++ examples/src/main/scala/Demo.scala | 7 ++++ 3 files changed, 80 insertions(+), 11 deletions(-) create mode 100644 examples/src/main/antlr/Chat.g4 create mode 100644 examples/src/main/scala/Demo.scala diff --git a/examples/build.gradle b/examples/build.gradle index 594f5c74dbf..dbef2d9fbe2 100644 --- a/examples/build.gradle +++ b/examples/build.gradle @@ -2,9 +2,11 @@ plugins { // Provide convenience executables for trying out the examples. id 'application' // ASSUMES GRADLE 5.6 OR HIGHER. Use plugin version 0.8.10 with earlier gradle versions - id 'com.google.protobuf' version '0.8.15' + id 'com.google.protobuf' version '0.8.16' // Generate IntelliJ IDEA's .idea & .iml project files id 'idea' + id 'scala' + id 'antlr' } repositories { @@ -27,6 +29,8 @@ def protobufVersion = '3.12.0' def protocVersion = protobufVersion dependencies { + antlr "org.antlr:antlr4:4.7.1" + implementation 'org.scala-lang:scala-library:2.12.8' implementation "io.grpc:grpc-protobuf:${grpcVersion}" implementation "io.grpc:grpc-stub:${grpcVersion}" compileOnly "org.apache.tomcat:annotations-api:6.0.53" @@ -41,22 +45,24 @@ dependencies { testImplementation "org.mockito:mockito-core:3.4.0" } +ext { + scalapbVersion = '0.10.10' +} + protobuf { protoc { artifact = "com.google.protobuf:protoc:${protocVersion}" } plugins { grpc { artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" } + scalapb { + artifact = (org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.getCurrentOperatingSystem().isWindows()) ? + "com.thesamet.scalapb:protoc-gen-scala:${scalapbVersion}:windows@bat" : + "com.thesamet.scalapb:protoc-gen-scala:${scalapbVersion}:unix@sh" + } } generateProtoTasks { - all()*.plugins { grpc {} } - } -} - -// Inform IDEs like IntelliJ IDEA, Eclipse or NetBeans about the generated code. -sourceSets { - main { - java { - srcDirs 'build/generated/source/proto/main/grpc' - srcDirs 'build/generated/source/proto/main/java' + all()*.plugins { + grpc {} + scalapb {} } } } diff --git a/examples/src/main/antlr/Chat.g4 b/examples/src/main/antlr/Chat.g4 new file mode 100644 index 00000000000..90290a20677 --- /dev/null +++ b/examples/src/main/antlr/Chat.g4 @@ -0,0 +1,56 @@ +grammar Chat; + +@header { +package net.davidesavazzi.mylanguage; +} + +/** + * Parser Rules + */ + +chat : line+ EOF ; + +line : name command message NEWLINE ; + +name : WORD WHITESPACE ; + +command : (SAYS | SHOUTS) ':' WHITESPACE ; + +message : (emoticon | link | color | mention | WORD | WHITESPACE)+ ; + +emoticon : ':' '-'? ')' + | ':' '-'? '(' ; + +link : '[' TEXT ']' '(' TEXT ')' ; + +color : '/' WORD '/' message '/' ; + +mention : '@' + WORD ; + + +/** + * Lexer Rules + */ + +fragment A : ('A' | 'a') ; +fragment S : ('S' | 's') ; +fragment Y : ('Y' | 'y') ; +fragment H : ('H' | 'h') ; +fragment O : ('O' | 'o') ; +fragment U : ('U' | 'u') ; +fragment T : ('T' | 't') ; + +fragment LOWERCASE : [a-z] ; +fragment UPPERCASE : [A-Z] ; + +SAYS : S A Y S ; + +SHOUTS : S H O U T S ; + +WORD : (LOWERCASE | UPPERCASE | '_')+ ; + +WHITESPACE : (' ' | '\t')+ ; + +NEWLINE : ('\r'? '\n' | '\r')+ ; + +TEXT : ('[' | '(') ~[\])]+ (']' | ')') ; \ No newline at end of file diff --git a/examples/src/main/scala/Demo.scala b/examples/src/main/scala/Demo.scala new file mode 100644 index 00000000000..b96f01feda4 --- /dev/null +++ b/examples/src/main/scala/Demo.scala @@ -0,0 +1,7 @@ + + +object Demo { + def main(args: Array[String]): Unit = { + println("hello world") + } +}