Loyc.Syntax.LNodeExt.GetCaptureIdentifier C# (CSharp) Method

GetCaptureIdentifier() public static method

Checks if pattern matches one of the syntax trees $x or $(..x) or $(...x) for some identifier x. These are conventionally used to represent partial syntax trees.
public static GetCaptureIdentifier ( LNode pattern, bool identifierRequired = true ) : LNode
pattern LNode
identifierRequired bool
return LNode
		public static LNode GetCaptureIdentifier(LNode pattern, bool identifierRequired = true)
		{
			if (pattern.Calls(S.Substitute, 1)) {
				var arg = pattern.Args.Last;
				if (arg.Calls(S.DotDot, 1) || arg.Calls(S.DotDotDot, 1))
					arg = arg.Args[0];
				if (arg.IsId || !identifierRequired)
					return arg;
			}
			return null;
		}