             }
         }
         return false
+    }
+    
+    func expression(for tokenName:String, in grammar:_STLR.Grammar) throws ->_STLR.Expression {
+        if let group = group {
+            return group.expression
+        } else if terminal != nil {
+            return _STLR.Expression.sequence(sequence: [self])
+        } else if let identifier = identifier {
+            if identifier == tokenName {
+                throw TestError.interpretationError(message: "Recursive inline definition of \(tokenName)", causes: [])
+            }
+            return grammar[identifier].expression
+        }
+        
+        fatalError("Unknown expression type")
     }
 }
 

import Foundation
import OysterKit

public extension _STLR.Grammar {
    public subscript(_ identifier:String)->_STLR.Rule{
        for rule in rules {
            if rule.identifier == identifier {
                return rule
            }
        }
        fatalError("Undefined identifier: \(identifier)")
    }
    
    public func isLeftHandRecursive(identifier:String)->Bool{

    /// The `Behaviour` of the rule
    public var behaviour : Behaviour {
        return Behaviour(kind, cardinality: cardinality, negated: isNegated, lookahead: isLookahead)
    }
    
    fileprivate func embeddedIdentifier(_ tokenName:String)->_STLR.Element?{
        if annotations?.token ?? "" == tokenName {
            return self
        }
        
        if let group = group {
            return group.expression.embeddedIdentifier(tokenName)
        } else if let _ = terminal {
            return nil
        } else if let _ = identifier{
            return nil
        }
        return nil
    }
    
    /**
