private static void ParseField(Lexer.Lexer lexer, out Exp k, out Exp v) { k = null; v = null; if (lexer.LookAhead() == ETokenType.SepLBracket) { lexer.NextToken(out _, out _, out _); k = ParseExp(lexer); lexer.NextTokenOfKind(ETokenType.SepRBracket, out _, out _); lexer.NextTokenOfKind(ETokenType.OpAssign, out _, out _); v = ParseExp(lexer); return; } var exp = ParseExp(lexer); if (exp is NameExp nameExp) { if (lexer.LookAhead() == ETokenType.OpAssign) { lexer.NextToken(out _, out _, out _); k = new StringExp { Line = nameExp.Line, Str = nameExp.Name }; v = ParseExp(lexer); return; } } v = exp; }
private static Exp FinishPrefixExp(Lexer.Lexer lexer, Exp exp) { while (true) { switch (lexer.LookAhead()) { case ETokenType.SepLBracket: { lexer.NextToken(out _, out _, out _); var keyExp = ParseExp(lexer); lexer.NextTokenOfKind(ETokenType.SepRBracket, out _, out _); exp = new TableAccessExp { LastLine = lexer.Line, PrefixExp = exp, KeyExp = keyExp }; break; } case ETokenType.SepDot: { lexer.NextToken(out _, out _, out _); lexer.NextIdentifier(out var line, out var name); var keyExp = new StringExp { Line = line, Str = name }; exp = new TableAccessExp { LastLine = line, PrefixExp = exp, KeyExp = keyExp }; break; } case ETokenType.SepColon: case ETokenType.SepLParen: case ETokenType.SepLCurly: case ETokenType.String: { exp = FinishFuncCallExp(lexer, exp); break; } default: return(exp); } } }
private static void ParseFuncName(Lexer.Lexer lexer, out Exp exp, out bool hasColon) { hasColon = false; lexer.NextIdentifier(out var line, out var name); exp = new NameExp { Line = line, Name = name }; while (lexer.LookAhead() == ETokenType.SepDot) { lexer.NextToken(out _, out _, out _); lexer.NextIdentifier(out line, out name); var idx = new StringExp { Line = line, Str = name }; exp = new TableAccessExp { LastLine = line, KeyExp = idx, PrefixExp = exp, }; } if (lexer.LookAhead() == ETokenType.SepColon) { lexer.NextToken(out _, out _, out _); lexer.NextIdentifier(out line, out name); var idx = new StringExp { Line = line, Str = name }; exp = new TableAccessExp { LastLine = line, PrefixExp = exp, KeyExp = idx, }; hasColon = true; } }
public void StringExp(StringExp e) { e.ExpType = typeof(CList); }
public void StringExp(StringExp e) { il.Emit(OpCodes.Ldstr, (e.Value)); il.Emit(OpCodes.Call, ((typeof(LispRuntime)).GetMethod("Init"))); }