From e317d65b456ff2f58f7a3dae110db7d5335978e8 Mon Sep 17 00:00:00 2001
From: overflowerror <mail@overflowerror.com>
Date: Sun, 16 Jan 2022 18:22:19 +0100
Subject: [PATCH] added token limit & debug flag to grammar ecore model

---
 .../emf-gen/org/eclipse/xtext/Grammar.java    |  46 +++++++
 .../org/eclipse/xtext/XtextPackage.java       |  58 ++++++++-
 .../org/eclipse/xtext/impl/GrammarImpl.java   | 112 ++++++++++++++++++
 .../eclipse/xtext/impl/XtextPackageImpl.java  |  24 ++++
 .../org/eclipse/xtext/Xtext.ecore             |   2 +
 .../org/eclipse/xtext/Xtext.genmodel          |   2 +
 6 files changed, 243 insertions(+), 1 deletion(-)

diff --git a/org.eclipse.xtext/emf-gen/org/eclipse/xtext/Grammar.java b/org.eclipse.xtext/emf-gen/org/eclipse/xtext/Grammar.java
index 43cc2c261..775459ed9 100644
--- a/org.eclipse.xtext/emf-gen/org/eclipse/xtext/Grammar.java
+++ b/org.eclipse.xtext/emf-gen/org/eclipse/xtext/Grammar.java
@@ -22,6 +22,8 @@ import org.eclipse.emf.ecore.EObject;
  *   <li>{@link org.eclipse.xtext.Grammar#getMetamodelDeclarations <em>Metamodel Declarations</em>}</li>
  *   <li>{@link org.eclipse.xtext.Grammar#getRules <em>Rules</em>}</li>
  *   <li>{@link org.eclipse.xtext.Grammar#getInitBlock <em>Init Block</em>}</li>
+ *   <li>{@link org.eclipse.xtext.Grammar#getTokenLimit <em>Token Limit</em>}</li>
+ *   <li>{@link org.eclipse.xtext.Grammar#isDebug <em>Debug</em>}</li>
  * </ul>
  *
  * @see org.eclipse.xtext.XtextPackage#getGrammar()
@@ -167,4 +169,48 @@ public interface Grammar extends EObject {
 	 */
 	void setInitBlock(InitBlock value);
 
+	/**
+	 * Returns the value of the '<em><b>Token Limit</b></em>' attribute.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @return the value of the '<em>Token Limit</em>' attribute.
+	 * @see #setTokenLimit(int)
+	 * @see org.eclipse.xtext.XtextPackage#getGrammar_TokenLimit()
+	 * @model
+	 * @generated
+	 */
+	int getTokenLimit();
+
+	/**
+	 * Sets the value of the '{@link org.eclipse.xtext.Grammar#getTokenLimit <em>Token Limit</em>}' attribute.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @param value the new value of the '<em>Token Limit</em>' attribute.
+	 * @see #getTokenLimit()
+	 * @generated
+	 */
+	void setTokenLimit(int value);
+
+	/**
+	 * Returns the value of the '<em><b>Debug</b></em>' attribute.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @return the value of the '<em>Debug</em>' attribute.
+	 * @see #setDebug(boolean)
+	 * @see org.eclipse.xtext.XtextPackage#getGrammar_Debug()
+	 * @model
+	 * @generated
+	 */
+	boolean isDebug();
+
+	/**
+	 * Sets the value of the '{@link org.eclipse.xtext.Grammar#isDebug <em>Debug</em>}' attribute.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @param value the new value of the '<em>Debug</em>' attribute.
+	 * @see #isDebug()
+	 * @generated
+	 */
+	void setDebug(boolean value);
+
 } // Grammar
diff --git a/org.eclipse.xtext/emf-gen/org/eclipse/xtext/XtextPackage.java b/org.eclipse.xtext/emf-gen/org/eclipse/xtext/XtextPackage.java
index a0d86fd8e..12f6525b0 100644
--- a/org.eclipse.xtext/emf-gen/org/eclipse/xtext/XtextPackage.java
+++ b/org.eclipse.xtext/emf-gen/org/eclipse/xtext/XtextPackage.java
@@ -130,6 +130,24 @@ public interface XtextPackage extends EPackage {
 	 */
 	int GRAMMAR__INIT_BLOCK = 6;
 
+	/**
+	 * The feature id for the '<em><b>Token Limit</b></em>' attribute.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 * @ordered
+	 */
+	int GRAMMAR__TOKEN_LIMIT = 7;
+
+	/**
+	 * The feature id for the '<em><b>Debug</b></em>' attribute.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 * @ordered
+	 */
+	int GRAMMAR__DEBUG = 8;
+
 	/**
 	 * The number of structural features of the '<em>Grammar</em>' class.
 	 * <!-- begin-user-doc -->
@@ -137,7 +155,7 @@ public interface XtextPackage extends EPackage {
 	 * @generated
 	 * @ordered
 	 */
-	int GRAMMAR_FEATURE_COUNT = 7;
+	int GRAMMAR_FEATURE_COUNT = 9;
 
 	/**
 	 * The meta object id for the '{@link org.eclipse.xtext.impl.AbstractRuleImpl <em>Abstract Rule</em>}' class.
@@ -2305,6 +2323,28 @@ public interface XtextPackage extends EPackage {
 	 */
 	EReference getGrammar_InitBlock();
 
+	/**
+	 * Returns the meta object for the attribute '{@link org.eclipse.xtext.Grammar#getTokenLimit <em>Token Limit</em>}'.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @return the meta object for the attribute '<em>Token Limit</em>'.
+	 * @see org.eclipse.xtext.Grammar#getTokenLimit()
+	 * @see #getGrammar()
+	 * @generated
+	 */
+	EAttribute getGrammar_TokenLimit();
+
+	/**
+	 * Returns the meta object for the attribute '{@link org.eclipse.xtext.Grammar#isDebug <em>Debug</em>}'.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @return the meta object for the attribute '<em>Debug</em>'.
+	 * @see org.eclipse.xtext.Grammar#isDebug()
+	 * @see #getGrammar()
+	 * @generated
+	 */
+	EAttribute getGrammar_Debug();
+
 	/**
 	 * Returns the meta object for class '{@link org.eclipse.xtext.AbstractRule <em>Abstract Rule</em>}'.
 	 * <!-- begin-user-doc -->
@@ -3389,6 +3429,22 @@ public interface XtextPackage extends EPackage {
 		 */
 		EReference GRAMMAR__INIT_BLOCK = eINSTANCE.getGrammar_InitBlock();
 
+		/**
+		 * The meta object literal for the '<em><b>Token Limit</b></em>' attribute feature.
+		 * <!-- begin-user-doc -->
+		 * <!-- end-user-doc -->
+		 * @generated
+		 */
+		EAttribute GRAMMAR__TOKEN_LIMIT = eINSTANCE.getGrammar_TokenLimit();
+
+		/**
+		 * The meta object literal for the '<em><b>Debug</b></em>' attribute feature.
+		 * <!-- begin-user-doc -->
+		 * <!-- end-user-doc -->
+		 * @generated
+		 */
+		EAttribute GRAMMAR__DEBUG = eINSTANCE.getGrammar_Debug();
+
 		/**
 		 * The meta object literal for the '{@link org.eclipse.xtext.impl.AbstractRuleImpl <em>Abstract Rule</em>}' class.
 		 * <!-- begin-user-doc -->
diff --git a/org.eclipse.xtext/emf-gen/org/eclipse/xtext/impl/GrammarImpl.java b/org.eclipse.xtext/emf-gen/org/eclipse/xtext/impl/GrammarImpl.java
index 3c4e974ea..b7b57f5ce 100644
--- a/org.eclipse.xtext/emf-gen/org/eclipse/xtext/impl/GrammarImpl.java
+++ b/org.eclipse.xtext/emf-gen/org/eclipse/xtext/impl/GrammarImpl.java
@@ -41,6 +41,8 @@ import org.eclipse.xtext.XtextPackage;
  *   <li>{@link org.eclipse.xtext.impl.GrammarImpl#getMetamodelDeclarations <em>Metamodel Declarations</em>}</li>
  *   <li>{@link org.eclipse.xtext.impl.GrammarImpl#getRules <em>Rules</em>}</li>
  *   <li>{@link org.eclipse.xtext.impl.GrammarImpl#getInitBlock <em>Init Block</em>}</li>
+ *   <li>{@link org.eclipse.xtext.impl.GrammarImpl#getTokenLimit <em>Token Limit</em>}</li>
+ *   <li>{@link org.eclipse.xtext.impl.GrammarImpl#isDebug <em>Debug</em>}</li>
  * </ul>
  *
  * @generated
@@ -136,6 +138,46 @@ public class GrammarImpl extends MinimalEObjectImpl.Container implements Grammar
 	 */
 	protected InitBlock initBlock;
 
+	/**
+	 * The default value of the '{@link #getTokenLimit() <em>Token Limit</em>}' attribute.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @see #getTokenLimit()
+	 * @generated
+	 * @ordered
+	 */
+	protected static final int TOKEN_LIMIT_EDEFAULT = 0;
+
+	/**
+	 * The cached value of the '{@link #getTokenLimit() <em>Token Limit</em>}' attribute.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @see #getTokenLimit()
+	 * @generated
+	 * @ordered
+	 */
+	protected int tokenLimit = TOKEN_LIMIT_EDEFAULT;
+
+	/**
+	 * The default value of the '{@link #isDebug() <em>Debug</em>}' attribute.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @see #isDebug()
+	 * @generated
+	 * @ordered
+	 */
+	protected static final boolean DEBUG_EDEFAULT = false;
+
+	/**
+	 * The cached value of the '{@link #isDebug() <em>Debug</em>}' attribute.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @see #isDebug()
+	 * @generated
+	 * @ordered
+	 */
+	protected boolean debug = DEBUG_EDEFAULT;
+
 	/**
 	 * <!-- begin-user-doc -->
 	 * <!-- end-user-doc -->
@@ -298,6 +340,52 @@ public class GrammarImpl extends MinimalEObjectImpl.Container implements Grammar
 			eNotify(new ENotificationImpl(this, Notification.SET, XtextPackage.GRAMMAR__INIT_BLOCK, newInitBlock, newInitBlock));
 	}
 
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	@Override
+	public int getTokenLimit() {
+		return tokenLimit;
+	}
+
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	@Override
+	public void setTokenLimit(int newTokenLimit) {
+		int oldTokenLimit = tokenLimit;
+		tokenLimit = newTokenLimit;
+		if (eNotificationRequired())
+			eNotify(new ENotificationImpl(this, Notification.SET, XtextPackage.GRAMMAR__TOKEN_LIMIT, oldTokenLimit, tokenLimit));
+	}
+
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	@Override
+	public boolean isDebug() {
+		return debug;
+	}
+
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	@Override
+	public void setDebug(boolean newDebug) {
+		boolean oldDebug = debug;
+		debug = newDebug;
+		if (eNotificationRequired())
+			eNotify(new ENotificationImpl(this, Notification.SET, XtextPackage.GRAMMAR__DEBUG, oldDebug, debug));
+	}
+
 	/**
 	 * <!-- begin-user-doc -->
 	 * <!-- end-user-doc -->
@@ -338,6 +426,10 @@ public class GrammarImpl extends MinimalEObjectImpl.Container implements Grammar
 				return getRules();
 			case XtextPackage.GRAMMAR__INIT_BLOCK:
 				return getInitBlock();
+			case XtextPackage.GRAMMAR__TOKEN_LIMIT:
+				return getTokenLimit();
+			case XtextPackage.GRAMMAR__DEBUG:
+				return isDebug();
 		}
 		return super.eGet(featureID, resolve, coreType);
 	}
@@ -376,6 +468,12 @@ public class GrammarImpl extends MinimalEObjectImpl.Container implements Grammar
 			case XtextPackage.GRAMMAR__INIT_BLOCK:
 				setInitBlock((InitBlock)newValue);
 				return;
+			case XtextPackage.GRAMMAR__TOKEN_LIMIT:
+				setTokenLimit((Integer)newValue);
+				return;
+			case XtextPackage.GRAMMAR__DEBUG:
+				setDebug((Boolean)newValue);
+				return;
 		}
 		super.eSet(featureID, newValue);
 	}
@@ -409,6 +507,12 @@ public class GrammarImpl extends MinimalEObjectImpl.Container implements Grammar
 			case XtextPackage.GRAMMAR__INIT_BLOCK:
 				setInitBlock((InitBlock)null);
 				return;
+			case XtextPackage.GRAMMAR__TOKEN_LIMIT:
+				setTokenLimit(TOKEN_LIMIT_EDEFAULT);
+				return;
+			case XtextPackage.GRAMMAR__DEBUG:
+				setDebug(DEBUG_EDEFAULT);
+				return;
 		}
 		super.eUnset(featureID);
 	}
@@ -435,6 +539,10 @@ public class GrammarImpl extends MinimalEObjectImpl.Container implements Grammar
 				return rules != null && !rules.isEmpty();
 			case XtextPackage.GRAMMAR__INIT_BLOCK:
 				return initBlock != null;
+			case XtextPackage.GRAMMAR__TOKEN_LIMIT:
+				return tokenLimit != TOKEN_LIMIT_EDEFAULT;
+			case XtextPackage.GRAMMAR__DEBUG:
+				return debug != DEBUG_EDEFAULT;
 		}
 		return super.eIsSet(featureID);
 	}
@@ -453,6 +561,10 @@ public class GrammarImpl extends MinimalEObjectImpl.Container implements Grammar
 		result.append(name);
 		result.append(", definesHiddenTokens: ");
 		result.append(definesHiddenTokens);
+		result.append(", tokenLimit: ");
+		result.append(tokenLimit);
+		result.append(", debug: ");
+		result.append(debug);
 		result.append(')');
 		return result.toString();
 	}
diff --git a/org.eclipse.xtext/emf-gen/org/eclipse/xtext/impl/XtextPackageImpl.java b/org.eclipse.xtext/emf-gen/org/eclipse/xtext/impl/XtextPackageImpl.java
index dacd9e411..c1b29d309 100644
--- a/org.eclipse.xtext/emf-gen/org/eclipse/xtext/impl/XtextPackageImpl.java
+++ b/org.eclipse.xtext/emf-gen/org/eclipse/xtext/impl/XtextPackageImpl.java
@@ -499,6 +499,26 @@ public class XtextPackageImpl extends EPackageImpl implements XtextPackage {
 		return (EReference)grammarEClass.getEStructuralFeatures().get(6);
 	}
 
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	@Override
+	public EAttribute getGrammar_TokenLimit() {
+		return (EAttribute)grammarEClass.getEStructuralFeatures().get(7);
+	}
+
+	/**
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	@Override
+	public EAttribute getGrammar_Debug() {
+		return (EAttribute)grammarEClass.getEStructuralFeatures().get(8);
+	}
+
 	/**
 	 * <!-- begin-user-doc -->
 	 * <!-- end-user-doc -->
@@ -1467,6 +1487,8 @@ public class XtextPackageImpl extends EPackageImpl implements XtextPackage {
 		createEReference(grammarEClass, GRAMMAR__METAMODEL_DECLARATIONS);
 		createEReference(grammarEClass, GRAMMAR__RULES);
 		createEReference(grammarEClass, GRAMMAR__INIT_BLOCK);
+		createEAttribute(grammarEClass, GRAMMAR__TOKEN_LIMIT);
+		createEAttribute(grammarEClass, GRAMMAR__DEBUG);
 
 		abstractRuleEClass = createEClass(ABSTRACT_RULE);
 		createEAttribute(abstractRuleEClass, ABSTRACT_RULE__NAME);
@@ -1674,6 +1696,8 @@ public class XtextPackageImpl extends EPackageImpl implements XtextPackage {
 		initEReference(getGrammar_MetamodelDeclarations(), this.getAbstractMetamodelDeclaration(), null, "metamodelDeclarations", null, 0, -1, Grammar.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
 		initEReference(getGrammar_Rules(), this.getAbstractRule(), null, "rules", null, 0, -1, Grammar.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
 		initEReference(getGrammar_InitBlock(), this.getInitBlock(), null, "initBlock", null, 0, 1, Grammar.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+		initEAttribute(getGrammar_TokenLimit(), ecorePackage.getEInt(), "tokenLimit", null, 0, 1, Grammar.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+		initEAttribute(getGrammar_Debug(), ecorePackage.getEBoolean(), "debug", null, 0, 1, Grammar.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
 
 		initEClass(abstractRuleEClass, AbstractRule.class, "AbstractRule", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
 		initEAttribute(getAbstractRule_Name(), theEcorePackage.getEString(), "name", null, 0, 1, AbstractRule.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
diff --git a/org.eclipse.xtext/org/eclipse/xtext/Xtext.ecore b/org.eclipse.xtext/org/eclipse/xtext/Xtext.ecore
index 1a7696c0e..1ab932718 100644
--- a/org.eclipse.xtext/org/eclipse/xtext/Xtext.ecore
+++ b/org.eclipse.xtext/org/eclipse/xtext/Xtext.ecore
@@ -14,6 +14,8 @@
         eType="#//AbstractRule" containment="true"/>
     <eStructuralFeatures xsi:type="ecore:EReference" name="initBlock" eType="#//InitBlock"
         containment="true"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="tokenLimit" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
+    <eStructuralFeatures xsi:type="ecore:EAttribute" name="debug" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
   </eClassifiers>
   <eClassifiers xsi:type="ecore:EClass" name="AbstractRule">
     <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType ../../../../org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/>
diff --git a/org.eclipse.xtext/org/eclipse/xtext/Xtext.genmodel b/org.eclipse.xtext/org/eclipse/xtext/Xtext.genmodel
index 12ea2fea4..e88527ea0 100644
--- a/org.eclipse.xtext/org/eclipse/xtext/Xtext.genmodel
+++ b/org.eclipse.xtext/org/eclipse/xtext/Xtext.genmodel
@@ -17,6 +17,8 @@
       <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference Xtext.ecore#//Grammar/metamodelDeclarations"/>
       <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference Xtext.ecore#//Grammar/rules"/>
       <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference Xtext.ecore#//Grammar/initBlock"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Xtext.ecore#//Grammar/tokenLimit"/>
+      <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Xtext.ecore#//Grammar/debug"/>
     </genClasses>
     <genClasses ecoreClass="Xtext.ecore#//AbstractRule">
       <genFeatures createChild="false" ecoreFeature="ecore:EAttribute Xtext.ecore#//AbstractRule/name"/>