package premun.mps.ingrid.parser.grammar;

public enum Quantity {
    EXACTLY_ONE,
    MAX_ONE,
    AT_LEAST_ONE,
    ANY;

    public String getCardinality() {
        switch (this) {
            case EXACTLY_ONE:
                return "1";

            case ANY:
                return "0..n";

            case AT_LEAST_ONE:
                return "1..n";

            case MAX_ONE:
                return "0..1";

            default:
                throw new IllegalArgumentException();
        }
    }

    public static Quantity FromString(String quantifier) {
        switch (quantifier) {
            case "?":
                return MAX_ONE;
            case "*":
            case "*?": // TODO: Has '*?' really this meaning?
                return ANY;
            case "+":
                return AT_LEAST_ONE;
            default:
                throw new IllegalArgumentException("Unknown quantification character '" + quantifier + "'");
        }
    }

    @Override
    public String toString() {
        switch (this) {
            case EXACTLY_ONE:
                return "";

            case ANY:
                return "*";

            case AT_LEAST_ONE:
                return "+";

            case MAX_ONE:
                return "?";

            default:
                throw new IllegalArgumentException();
        }
    }
}

@@ -615,16 +615,115 @@
 se %22?%22:%0A
+            case %22??%22: // non-greedy (https://github.com/antlr/antlr4/blob/master/doc/wildcard.md)%0A
         
@@ -742,24 +742,25 @@
 rn MAX_ONE;%0A
+%0A
             
@@ -799,43 +799,80 @@
  // 
-TODO: Has '*?' really this meaning?
+non-greedy (https://github.com/antlr/antlr4/blob/master/doc/wildcard.md)
 %0A   
@@ -896,16 +896,17 @@
 rn ANY;%0A
+%0A
         
@@ -919,16 +919,115 @@
 se %22+%22:%0A
+            case %22+?%22: // non-greedy (https://github.com/antlr/antlr4/blob/master/doc/wildcard.md)%0A
         
@@ -1055,16 +1055,17 @@
 ST_ONE;%0A
+%0A
         

Add non-greedy quantifiers