Skip to content

Commit

Permalink
Revert "Java Backend: Re-support cup version 0.11a"
Browse files Browse the repository at this point in the history
This reverts commit a65a265.

The location tracking of cup was really awful in 0.11a, so much so that tracking
locations in the abstract syntax tree is basically impossible. Revert this
commit and add a comment about the minimal version required when line numbering
is requested. Verified that cup 0.11a is supported without line numbering.
  • Loading branch information
iteratee committed Jan 12, 2018
1 parent 292b612 commit 2552ae9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
19 changes: 11 additions & 8 deletions source/src/BNFC/Backend/Java/CFtoJLex15.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,28 @@ prelude (ln, jflex) packageBase = vcat
, (if ln
then vcat
[ "%line"
, (if jflex then "%column" else "") ]
, (if jflex then "%column" else "")
, "%char" ]
else "")
, "%public"
, "%{"
, nest 2 $ vcat
[ "String pstring = new String();"
, "final int unknown = -1;"
, "ComplexSymbolFactory.Location left = new ComplexSymbolFactory.Location(unknown, unknown);"
, "ComplexSymbolFactory.Location left;"
, "ComplexSymbolFactory cf = new ComplexSymbolFactory();"
, positionDeclarations
, "public int line_num() { return (yyline+1); }"
, "public ComplexSymbolFactory.Location left_loc() {"
, " return new ComplexSymbolFactory.Location(yyline+1, yycolumn+1);"
, if ln
then " return new ComplexSymbolFactory.Location(yyline+1, yycolumn+1, yychar);"
else " return null;"
, "}"
, "public ComplexSymbolFactory.Location right_loc() {"
, " ComplexSymbolFactory.Location left = left_loc();"
, (if ln
then " return new ComplexSymbolFactory.Location(left.getLine(), left.getColumn()+yylength());"
else " return left;")
then "return new ComplexSymbolFactory.Location(left.line, left.column+yylength(), left.offset+yylength());"
else "return left;")
, "}"
, "public String buff()" <+> braces
(if jflex
Expand All @@ -105,10 +108,10 @@ prelude (ln, jflex) packageBase = vcat
if jflex then ""
else if ln then "int yycolumn = unknown - 1;"
else vcat
-- subtract one so that one based numbering still ends up with
-- unknown.
-- subtract one so that one based numbering still ends up with unknown.
[ "int yyline = unknown - 1;"
, "int yycolumn = unknown - 1;" ]
, "int yycolumn = unknown - 1;"
, "int yychar = unknown;" ]

--For now all categories are included.
--Optimally only the ones that are used should be generated.
Expand Down
2 changes: 1 addition & 1 deletion source/src/BNFC/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ targetOptions =
specificOptions :: [(OptDescr (SharedOptions -> SharedOptions), [Target])]
specificOptions =
[ ( Option ['l'] [] (NoArg (\o -> o {linenumbers = True}))
"Add and set line_number field for all syntax classes"
"Add and set line_number field for all syntax classes\nJava requires cup 0.11b-2014-06-11 or greater"
, [TargetCpp, TargetJava] )
, ( Option ['p'] []
(ReqArg (\n o -> o {inPackage = Just n}) "<namespace>")
Expand Down

0 comments on commit 2552ae9

Please sign in to comment.