public ExternFunctionToken(Token parent, Scope scope, IEnumerable<Token> tokens, Token dataTypeToken, IdentifierToken nameToken, BracketsToken argsToken) : base(parent, scope, new Span(tokens.First().Span.Start, tokens.Last().Span.End)) { _tokens = tokens.ToArray(); _dataTypeToken = dataTypeToken; _nameToken = nameToken; _argsToken = argsToken; }
public FunctionCallToken(Token parent, Scope scope, IdentifierToken nameToken, BracketsToken argsToken) : base(parent, scope, new Span(nameToken.Span.Start, argsToken.Span.End)) { _nameToken = nameToken; _argsToken = argsToken; _nameToken.Parent = this; _argsToken.Parent = this; }
private DefineToken(Token parent, Scope scope, IEnumerable<Token> tokens, IdentifierToken nameToken, BracketsToken argsToken, IEnumerable<Token> bodyTokens) : base(parent, scope, new Span(tokens.First().Span.Start, tokens.Last().Span.End)) { _tokens = tokens.ToArray(); foreach (var token in _tokens) token.Parent = this; _nameToken = nameToken; _argsToken = argsToken; _bodyTokens = bodyTokens.ToArray(); if (_argsToken == null && _bodyTokens.Length == 1 && (_bodyTokens[0].GetType() == typeof(DataTypeToken) || _bodyTokens[0].GetType() == typeof(DataTypeKeywordToken))) { _isDataType = true; //File.AddDefinedDataType(_nameToken.Text); } }
public FunctionToken(Token parent, Scope scope, IEnumerable<Token> tokens, Token dataTypeToken, IdentifierToken nameToken, BracketsToken argsToken, BracesToken scopeToken) : base(parent, scope, new Span(tokens.First().Span.Start, tokens.Last().Span.End)) { _tokens = tokens.ToArray(); _dataTypeToken = dataTypeToken; if (_dataTypeToken != null) _dataTypeToken.Parent = this; _nameToken = nameToken; _nameToken.Parent = this; _argsToken = argsToken; _argsToken.Parent = this; _scopeToken = scopeToken; _scopeToken.Parent = this; foreach (var tok in _tokens) tok.Parent = this; }
public static BracketsToken Parse(Token parent, Scope scope) { var file = scope.File; var startPos = file.Position; file.MoveNext(); var scopeIndent = scope.IndentNonRoot(); scopeIndent.Hint |= ScopeHint.SuppressVarDecl | ScopeHint.SuppressFunctionDefinition | ScopeHint.SuppressFunctionCall; var retToken = new BracketsToken(parent, scope, new Span(startPos, startPos)); retToken._openToken = new BracketToken(retToken, scope, new Span(startPos, file.Position), retToken, true); retToken._tokens.Add(retToken._openToken); var closeToken = null as Token; var done = false; while (!file.EndOfFile && !done) { var token = file.ParseToken(retToken, scopeIndent); if (token != null) { if (token.GetType() == typeof(OperatorToken) && token.Text == ")") { retToken._closeToken = new BracketToken(retToken, scope, token.Span, retToken, false); retToken._tokens.Add(retToken._closeToken); done = true; } else { retToken._tokens.Add(token); } } } retToken.Span = new Span(startPos, file.Position); return retToken; }
public BracketToken(Token parent, Scope scope, Span span, BracketsToken bracketsToken, bool open) : base(parent, scope, span) { _bracketsToken = bracketsToken; _open = open; }