grammar-redundant-condition

A condition tag that holds wherever its construct can occur.

Group
Urscal grammars
Runs
On by default
Level
warning
Reads
Every file
Fix
--fix fixes it: removes the condition tags

Why

The condition tags on a construct hold for every release, dialect, and set of features that the constructs around it allow, so they neither restrict nor date it. Remove them.

The fix, as Ur suggests it: remove the condition tags.

For agents

Tag a construct with a condition only where it narrows what the constructs around it already allow.

Example

calc/Calc.rsc
module calc::Calc

track Calc = "1" "2";
dialect Standard uses Calc;
profile "calc-1" = Standard Calc "1";
profile "calc-2" = Standard Calc "2";

lexical Name = [a-z]+ \ Reserved;
lexical Number = [0-9]+;
layout Space = [\  \n]+;
keyword Reserved = "let" | "print";

start syntax Program = Program: Statement* statements;
syntax Statement
  = @since="1" Let: "let" Name name "=" Expr value
  | @since="2" Print: "print" Expr value;
syntax Expr = Variable: Name name | Literal: Number number;
What Ur prints
$ ur lint --rule grammar-redundant-condition
warning[grammar-redundant-condition]: the conditions on the alternative `Let` of `Statement` hold wherever it can occur, so they have no effect
  --> ./calc/Calc.rsc:15:5 a condition that always holds
  = hint: remove the condition tags; `--fix` does this
  = see: Feature Consistency in Compile-Time-Configurable System Software, Reinhard Tartler, Daniel Lohmann, Julio Sincero, and Wolfgang Schröder-Preikschat, EuroSys 2011 (2011-04), http://www4.cs.fau.de/Publications/2011/tartler_11_eurosys.pdf
0 clone classes and 1 grammar finding in 1 file

Try it in the playground →

Source

Feature Consistency in Compile-Time-Configurable System Software, Reinhard Tartler, Daniel Lohmann, Julio Sincero, and Wolfgang Schröder-Preikschat, EuroSys 2011 (2011-04).