jprante / gradle-plugin-jflex

A JFlex plugin for Gradle
Apache License 2.0
8 stars 6 forks source link

slight issue with the readme #2

Open SingingBush opened 7 years ago

SingingBush commented 7 years ago

in your readme the groupId for the plugin is org.xbib.gradle.plugins:

    dependencies {
        classpath 'org.xbib.gradle.plugins:gradle-plugin-jflex:1.1.0'
    }

but that doesn't tally up with your maven repository org.xbib.gradle.plugin: http://xbib.org/repository/org/xbib/gradle/plugin/gradle-plugin-jflex/

jprante commented 7 years ago

Thanks. I fixed the typo.

SingingBush commented 7 years ago

wow that was quick. I'm having a slight issue. after running the jflex task I can see the generated-src in the build directory but it's empty. I have a flex file in src/main/jflex and when running the task there wasn't any error messages

jprante commented 7 years ago

What Gradle version do you use?

SingingBush commented 7 years ago

3.3

jprante commented 7 years ago

Can you give an example jflex? I would like to check if there is an issue with package configuration.

The result should be in directory build/generated-src/jflex

SingingBush commented 7 years ago

sure. It's likely to have problems. I've just started on it today and have never used jflex before

package com.singingbush.sdlplugin.lexer;

import com.intellij.lexer.*;
import com.intellij.psi.tree.IElementType;

%%

%{

  private int nestedCommentDepth = 0;
  private int blockCommentDepth = 0;

  public SdlLexer() {
    this((java.io.Reader)null);
  }
%}

%public
%class SdlLexer
%implements FlexLexer
%function advance
%type IElementType
%unicode

EOL = "\n"
WHITE_SPACE_CHAR = [\ \t\f]
NEW_LINE = [\n\r]+
// maybe better off making NEW_LINE = [^\n]*

LETTER = [:letter:]
DIGIT = [:digit:]
ID = (_|{LETTER}) (_|{DIGIT}|{LETTER})*

LINE_COMMENT="//".*

BLOCK_COMMENT_START = "/*"
BLOCK_COMMENT_END = "*/"

%xstate BRACES, VALUE, VALUE_OR_KEY, VALUE_BRACE, INDENT_VALUE
// %state WAITING_VALUE, NESTING_COMMENT_CONTENT BLOCK_COMMENT_CONTENT

%%

<YYINITIAL> {WHITE_SPACE_CHAR}+ { return com.intellij.psi.TokenType.WHITE_SPACE; }
<YYINITIAL> {NEW_LINE}+         { return com.intellij.psi.TokenType.WHITE_SPACE; }

<YYINITIAL, BRACES, VALUE, VALUE_BRACE, VALUE_OR_KEY> {
    ";" {
        return EOL
    }
}

For now I'm just trying to get something running so I've at least got something to build on. It's for getting Intellij to support https://sdlang.org/

jprante commented 7 years ago

Can you check out https://github.com/jprante/jflex-example ?

When I enter ./gradlew jflex I see the java source in ./build/generated-src/jflex/com/singingbush/sdlplugin/lexer/SdlLexer.java

SingingBush commented 7 years ago

ok that's odd. I checked out the repo and ran ./gradlew jflex and it worked fine. I tried changing gradle version in my project to 3.5 as that's what you have in that example but it still won't generate a Java file.

I'm using the jflex plugin in a module of a multi-module project so I tried restructuring the example so that it a sub module but it still worked fine. I wonder if the problem I'm seeing is due to other plugins I'm using. Besides yours I'm also using 'org.jetbrains.intellij' and 'kotlin'

jprante commented 7 years ago

Thanks for reporting back.

I will try to investigate to find out such situations when jflex might not write out to the specified directory, or situations when jflex fails (silently).

SingingBush commented 7 years ago

I'm making some progress with this jflex stuff albeit slow. 2 of the 3 flex files I have are generating Java classes.

It would be good if the plugin did more logging. When running gradle with --info or --debug there's no information about problems with the flex file that isn't producing a Java class.