Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@regisd
Copy link
Member

@regisd regisd commented Sep 24, 2018

Emit in the header of the generated java source the path of the lex file.

Emit in the header of the generated java source the path of the lex file.
@regisd regisd self-assigned this Sep 24, 2018
@regisd regisd requested a review from lsf37 September 24, 2018 15:44
@regisd regisd added this to the 1.7.1 milestone Sep 24, 2018
@regisd regisd added the enhancement Feature requests label Sep 24, 2018
@regisd regisd changed the title Indicate in the lex file in the header of the java source Indicate the lex source file in the header of the java source Sep 24, 2018
Copy link
Member

@lsf37 lsf37 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is slightly problematic (I think I had this in early versions of JFlex), because it can leave machine-local paths in the generated sources (like /home/xyz/src/blah/), which is usually no problem, but some people really don't like to reveal those details.

We could make it configurable, i.e. add an option to turn it off.

@regisd
Copy link
Member Author

regisd commented Sep 25, 2018

I agree, this shouldn't include the working directory.

This allows to invoke mvn from anywhere and always emit the same header.

e.g.
```
// DO NOT EDIT
// Generated by JFlex 1.7.1-SNAPSHOT
// source: src/main/jflex/lcalc.flex
```
@regisd
Copy link
Member Author

regisd commented Sep 25, 2018

cd jflex/examples
mvn -pl cup-maven clean generate-sources
head cup-maven/target/generated-sources/jflex/Lexer.java

returns:

[INFO] Total time: 0.747 s
[INFO] Finished at: 2018-09-25T13:05:09+02:00
[INFO] Final Memory: 25M/974M
[INFO] ------------------------------------------------------------------------
// DO NOT EDIT
// Generated by JFlex 1.7.1-SNAPSHOT
// source: src/main/jflex/lcalc.flex

/*
  This example comes from a short article series in the Linux 
  Gazette by Richard A. Sevenich and Christopher Lopes, titled
  "Compiler Construction Tools". The article series starts at

  http://www.linuxgazette.com/issue39/sevenich.html

@regisd
Copy link
Member Author

regisd commented Sep 25, 2018

PTAL

Copy link
Member

@lsf37 lsf37 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, this looks good in terms of path, let's merge it. If someone doesn't like it we can still add an option then.

@regisd regisd merged commit b9fa958 into jflex-de:master Sep 28, 2018
@regisd regisd deleted the emitter-lexfile branch September 28, 2018 09:58
regisd pushed a commit that referenced this pull request Sep 28, 2018
Initial commit b9fa958
Author: Régis Décamps <[email protected]>
Date:   Fri Sep 28 11:58:35 2018 +0200

    Indicate the lex source file in the header of the java source (#371)

    * Indicate in the source lexFile in the header of the java source
      - Emit in the header of the generated java source the path of the lex file.
      - Do not show the working directory, only the relative path to the working directory.
    * Set the source directory in the jflex-maven-plugin

    e.g.
    ```
    // DO NOT EDIT
    // Generated by JFlex 1.7.1-SNAPSHOT
    // source: src/main/jflex/lcalc.flex
    ```
regisd added a commit to regisd/jflex that referenced this pull request Sep 30, 2018
@regisd
Copy link
Member Author

regisd commented Sep 30, 2018

Follow-up in #397

regisd added a commit to regisd/jflex that referenced this pull request Sep 30, 2018
regisd added a commit that referenced this pull request Sep 30, 2018
regisd pushed a commit that referenced this pull request Sep 30, 2018
Initial commit 3936f66
Author: Régis Décamps <[email protected]>
Date:   Sun Sep 30 18:25:06 2018 +0200

    Remove duplicate "This class is generated by JFlex" (#397)

    A better header is emitted since #371 commit b9fa958
@lsf37 lsf37 modified the milestones: 1.7.1, 1.8.0 Feb 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Feature requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants