context: // Generated from LesParserGrammar.les by LeMP custom tool. LeMP version: 1.4.1.0
  // Note: you can give command-line arguments to the tool via 'Custom Tool Namespace':
  // --no-out-header       Suppress this message
  // --verbose             Allow verbose messages (shown by VS as 'warnings')
  // --timeout=X           Abort processing thread after X seconds (default: 10)
  // --macros=FileName.dll Load macros from FileName.dll, path relative to this file 
  // Use #importMacros to use macros in a given namespace, e.g. #importMacros(Loyc.LLPG);
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using Loyc;
  using Loyc.Collections;
  using Loyc.Syntax;
  using Loyc.Syntax.Lexing;
  namespace Loyc.Syntax.Les
  {
  	using TT = TokenType;
  	using S = CodeSymbols;
  	using P = LesPrecedence;
  	#pragma warning disable 162, 642
  	public partial class LesParser
  	{
  		public VList<LNode> ExprList(VList<LNode> list = default(VList<LNode>))
  		{
  			var endMarker = default(TT);
  			return (ExprList(ref endMarker, list));
  		}
  		void CheckEndMarker(ref TokenType endMarker, ref Token end)
  		{
  			if ((endMarker != end.Type())) {
  				if ((endMarker == default(TT))) {
  					endMarker = end.Type();
  				} else {
  					Error(-1, "Unexpected separator: {0} should be {1}", ToString(end.TypeInt), ToString((int) endMarker));
  				}
  			}
  		}
  		public VList<LNode> StmtList()
  		{
  			VList<LNode> result = default(VList<LNode>);
  			var endMarker = TT.Semicolon;
  			result = ExprList(ref endMarker);
  			return result;
  		}
  		public VList<LNode> ExprList(ref TokenType endMarker, VList<LNode> list = default(VList<LNode>))
  		{
  			TT la0;
  			LNode e = default(LNode);
  			Token end = default(Token);
  			// line 57
  			if ((LT0.Value is string)) {
  				endMarker = TT.EOF;
  			}
  			// Line 1: ( / TopExpr)
  			switch ((TT) LA0) {
  			case EOF:
  			case TT.Comma:
  			case TT.Dedent:
  			case TT.RBrace:
  			case TT.RBrack:
  			case TT.RParen:
  			case TT.Semicolon:
  				{
  				}
  				break;
  			default:
  				e = TopExpr();
  				break;
  			}
  			// Line 59: ((TT.Comma|TT.Semicolon) ( / TopExpr))*
  			for (;;) {
  				la0 = (TT) LA0;
  				if (la0 == TT.Comma || la0 == TT.Semicolon) {
  					end = MatchAny();
  					list.Add(e ?? MissingExpr());
  					CheckEndMarker(ref endMarker, ref end);
  					// Line 62: ( / TopExpr)
  					switch ((TT) LA0) {
  					case EOF:
  					case TT.Comma:
  					case TT.Dedent:
  					case TT.RBrace:
  					case TT.RBrack:
  					case TT.RParen:
  					case TT.Semicolon:
  						// line 62
  						e = null;
  						break;
  					default:
  						e = TopExpr();
  						break;
  					}
  				} else
  					break;
  			}
  			if ((e != null || end.Type() == TT.Comma)) {
  				list.Add(e ?? MissingExpr());
  			}
  			return list;
  		}
  		public IEnumerable<LNode> ExprListLazy(Holder<TokenType> endMarker)
  		{
  			TT la0;
  			LNode e = default(LNode);
  			Token end = default(Token);
  			// line 68
  			if ((LT0.Value is string)) {
  				endMarker = TT.EOF;
  			}
  			// Line 1: ( / TopExpr)
  			la0 = (TT) LA0;
  			if (la0 == (TT) EOF || la0 == TT.Comma || la0 == TT.Semicolon) {
  			} else
  				e = TopExpr();
  			// Line 70: ((TT.Comma|TT.Semicolon) ( / TopExpr))*
  			for (;;) {
  				la0 = (TT) LA0;
  				if (la0 == TT.Comma || la0 == TT.Semicolon) {
  					end = MatchAny();
  					// line 71
  					yield
  					return e ?? MissingExpr();
  					CheckEndMarker(ref endMarker.Value, ref end);
  					// Line 73: ( / TopExpr)
  					la0 = (TT) LA0;
  					if (la0 == (TT) EOF || la0 == TT.Comma || la0 == TT.Semicolon)
  						// line 73
  						e = null;
  					else
  						e = TopExpr();
  				} else
  					break;
  			}
  			// line 75
  			if ((e != null || end.Type() == TT.Comma)) {
  				yield return e ?? MissingExpr();
  			}
  		}
  		protected LNode TopExpr()
  		{
  			TT la0, la1;
  			Token at = default(Token);
  			VList<LNode> attrs = default(VList<LNode>);
  			LNode e = default(LNode);
  			Token t = default(Token);
  			// Line 91: greedy((TT.At)? TT.LBrack ExprList TT.RBrack)?
  			do {
  				la0 = (TT) LA0;
  				if (la0 == TT.At) {
  					la1 = (TT) LA(1);
  					if (la1 == TT.LBrack)
  						goto match1;
  				} else if (la0 == TT.LBrack) {
  					switch ((TT) LA(1)) {
  					case TT.Assignment:
  					case TT.At:
  					case TT.BQString:
  					case TT.Colon:
  					case TT.Comma:
  					case TT.Dot:
  					case TT.Id:
  					case TT.LBrace:
  					case TT.LBrack:
  					case TT.Literal:
  					case TT.LParen:
  					case TT.NormalOp:
  					case TT.Not:
  					case TT.PrefixOp:
  					case TT.PreOrSufOp:
  					case TT.RBrack:
  					case TT.Semicolon:
  					case TT.SpaceLParen:
  						goto match1;
  					}
  				}
  				break;
  			match1:
  				{
  					// Line 91: (TT.At)?
  					la0 = (TT) LA0;
  					if (la0 == TT.At)
  						at = MatchAny();
  					// line 92
  					if (at.Type() == default(TT)) {
  						ErrorSink.Write(Severity.Warning, LaIndexToContext(0), "Attribute: expected '@['");
  					}
  					t = Match((int) TT.LBrack);
  					attrs = ExprList();
  					Match((int) TT.RBrack);
  				}
  			} while (false);
  			// Line 95: (Expr / TT.Id Expr (Particle)*)
  			do {
  				switch ((TT) LA0) {
  				case TT.Assignment:
  				case TT.BQString:
  				case TT.Dot:
  				case TT.NormalOp:
  				case TT.Not:
  				case TT.PrefixOp:
  				case TT.PreOrSufOp:
  					e = Expr(StartStmt);
  					break;
  				case TT.Id:
  					{
  						switch ((TT) LA(1)) {
  						case TT.Assignment:
  						case TT.BQString:
  						case TT.Dot:
  						case TT.NormalOp:
  							e = Expr(StartStmt);
  							break;
  						case TT.Colon:
  							{
  								if (LA(1 + 1) != (int) TT.Indent)
  									e = Expr(StartStmt);
  								else
  									goto match2;
  							}
  							break;
  						case EOF:
  						case TT.Comma:
  						case TT.Dedent:
  						case TT.LBrack:
  						case TT.LParen:
  						case TT.Not:
  						case TT.PreOrSufOp:
  						case TT.RBrace:
  						case TT.RBrack:
  						case TT.RParen:
  						case TT.Semicolon:
  							e = Expr(StartStmt);
  							break;
  						default:
  							goto match2;
  						}
  					}
  					break;
  				default:
  					e = Expr(StartStmt);
  					break;
  				}
  				break;
  			match2:
  				{
  					var id = MatchAny();
  					// line 98
  					var args = VList<LNode>.Empty;
  					args.Add(Expr(P.SuperExpr));
  					// Line 100: (Particle)*
  					for (;;) {
  						switch ((TT) LA0) {
  						case TT.At:
  						case TT.Colon:
  						case TT.Id:
  						case TT.LBrace:
  						case TT.LBrack:
  						case TT.Literal:
  						case TT.LParen:
  						case TT.SpaceLParen:
  							{
  								// line 101
  								if (((TT) LA0 == TT.LParen)) {
  									var loc = args[args.Count - 2, args.Last].Range.End;
  									Error(0, "Expected a space before '(' (possibly missing ';' or ',' at {0})", loc);
  								}
  								args.Add(Particle());
  							}
  							break;
  						default:
  							goto stop;
  						}
  					}
  				stop:;
  					// line 108
  					e = MarkSpecial(F.Call(id, args, id.StartIndex, args.Last.Range.EndIndex));
  				}
  			} while (false);
  			if ((t.TypeInt != 0)) {
  				e = e.WithRange(t.StartIndex, e.Range.EndIndex);
  			}
  			return e.PlusAttrs(attrs);
  		}
  		LNode Expr(Precedence context)
  		{
  			LNode e = default(LNode);
  			Token t = default(Token);
  			// line 123
  			Precedence prec;
  			e = PrefixExpr(context);
  			// Line 127: greedy( &{context.CanParse(prec = InfixPrecedenceOf(LT($LI)))} ((TT.Assignment|TT.BQString|TT.Dot|TT.NormalOp) | &{LA($LI + 1) != TT.Indent->@int} TT.Colon) Expr | &{context.CanParse(P.Primary)} FinishPrimaryExpr | &{context.CanParse(SuffixPrecedenceOf(LT($LI)))} TT.PreOrSufOp )*
  			for (;;) {
  				switch ((TT) LA0) {
  				case TT.Assignment:
  				case TT.BQString:
  				case TT.Dot:
  				case TT.NormalOp:
  					{
  						if (context.CanParse(prec = InfixPrecedenceOf(LT(0))))
  							goto matchExpr;
  						else
  							goto stop;
  					}
  				case TT.Colon:
  					{
  						if (LA(0 + 1) != (int) TT.Indent) {
  							if (context.CanParse(prec = InfixPrecedenceOf(LT(0))))
  								goto matchExpr;
  							else
  								goto stop;
  						} else
  							goto stop;
  					}
  				case TT.LBrack:
  				case TT.LParen:
  				case TT.Not:
  					{
  						if (context.CanParse(P.Primary))
  							e = FinishPrimaryExpr(e);
  						else
  							goto stop;
  					}
  					break;
  				case TT.PreOrSufOp:
  					{
  						if (context.CanParse(SuffixPrecedenceOf(LT(0)))) {
  							t = MatchAny();
  							// line 140
  							e = F.Call(ToSuffixOpName((Symbol) t.Value), e, e.Range.StartIndex, t.EndIndex).SetStyle(NodeStyle.Operator);
  						} else
  							goto stop;
  					}
  					break;
  				default:
  					goto stop;
  				}
  				continue;
  			matchExpr:
  				{
  					// line 128
  					if ((!prec.CanMixWith(context))) {
  						Error(0, "Operator '{0}' is not allowed in this context. Add parentheses to clarify the code's meaning.", LT0.Value);
  					}
  					// Line 131: ((TT.Assignment|TT.BQString|TT.Dot|TT.NormalOp) | &{LA($LI + 1) != TT.Indent->@int} TT.Colon)
  					switch ((TT) LA0) {
  					case TT.Assignment:
  					case TT.BQString:
  					case TT.Dot:
  					case TT.NormalOp:
  						t = MatchAny();
  						break;
  					default:
  						{
  							Check(LA(0 + 1) != (int) TT.Indent, "LA($LI + 1) != TT.Indent->@int");
  							t = Match((int) TT.Colon);
  						}
  						break;
  					}
  					var rhs = Expr(prec);
  					// line 133
  					e = F.Call((Symbol) t.Value, e, rhs, e.Range.StartIndex, rhs.Range.EndIndex).SetStyle(NodeStyle.Operator);
  				}
  			}
  		stop:;
  			// line 142
  			return e;
  		}
  		LNode FinishPrimaryExpr(LNode e)
  		{
  			TT la0;
  			VList<LNode> list = default(VList<LNode>);
  			// Line 148: ( TT.LParen ExprList TT.RParen | TT.Not (TT.LParen ExprList TT.RParen / Expr) | TT.LBrack ExprList TT.RBrack )
  			la0 = (TT) LA0;
  
gt: 			if (la0 == TT.LParen) {