public ArrayTypeNode(Token arrayKeywordNode, Token openBracketNode, ListNode<DelimitedItemNode<AstNode>> indexListNode, Token closeBracketNode, Token ofKeywordNode, AstNode typeNode) { _arrayKeywordNode = arrayKeywordNode; _openBracketNode = openBracketNode; _indexListNode = indexListNode; _closeBracketNode = closeBracketNode; _ofKeywordNode = ofKeywordNode; _typeNode = typeNode; }
public AnonMethodHeadingNode(Token methodType, Token openParenthesis, ListNode<DelimitedItemNode<ParameterNode>> parameterList, Token closeParenthesis, Token colon, AstNode returnType) { MethodType = methodType; OpenParenthesis = openParenthesis; ParameterList = parameterList; CloseParenthesis = closeParenthesis; Colon = colon; ReturnType = returnType; }
public Token NextToken() { while(_index < _source.Length && Char.IsWhiteSpace(_source[_index])) ++_index; if(_index >= _source.Length) return null; Match match = NextMatch(); if(match == null) throw new LexException("Unrecognized character '" + _source[_index] + "'", Location); string text = _source.Substring(_index, match.Length); Token result = new Token(match.TokenType, Location, text, match.ParsedText); _index += match.Length; return result; }
public virtual void VisitToken(Token token) { }
public ConstantDeclNode(Token nameNode, Token colonNode, AstNode typeNode, Token equalSignNode, AstNode valueNode, ListNode<Token> portabilityDirectiveListNode, Token semicolonNode) { _nameNode = nameNode; _colonNode = colonNode; _typeNode = typeNode; _equalSignNode = equalSignNode; _valueNode = valueNode; _portabilityDirectiveListNode = portabilityDirectiveListNode; _semicolonNode = semicolonNode; }
public ClassOfNode(Token classKeywordNode, Token ofKeywordNode, AstNode typeNode) { _classKeywordNode = classKeywordNode; _ofKeywordNode = ofKeywordNode; _typeNode = typeNode; }
public WhileStatementNode(Token whileKeywordNode, AstNode conditionNode, Token doKeywordNode, AstNode statementNode) { _whileKeywordNode = whileKeywordNode; _conditionNode = conditionNode; _doKeywordNode = doKeywordNode; _statementNode = statementNode; }
public VarSectionNode(Token varKeywordNode, ListNode<VarDeclNode> varListNode) { _varKeywordNode = varKeywordNode; _varListNode = varListNode; }
public VariantGroupNode(ListNode<DelimitedItemNode<AstNode>> valueListNode, Token colonNode, Token openParenthesisNode, ListNode<FieldDeclNode> fieldDeclListNode, VariantSectionNode variantSectionNode, Token closeParenthesisNode, Token semicolonNode) { _valueListNode = valueListNode; _colonNode = colonNode; _openParenthesisNode = openParenthesisNode; _fieldDeclListNode = fieldDeclListNode; _variantSectionNode = variantSectionNode; _closeParenthesisNode = closeParenthesisNode; _semicolonNode = semicolonNode; }
public TypeForwardDeclarationNode(Token nameNode, Token equalSignNode, Token typeNode, Token semicolonNode) { _nameNode = nameNode; _equalSignNode = equalSignNode; _typeNode = typeNode; _semicolonNode = semicolonNode; }
public TypeDeclNode(Token nameNode, Token equalSignNode, Token typeKeywordNode, AstNode typeNode, ListNode<Token> portabilityDirectiveListNode, Token semicolonNode) { _nameNode = nameNode; _equalSignNode = equalSignNode; _typeKeywordNode = typeKeywordNode; _typeNode = typeNode; _portabilityDirectiveListNode = portabilityDirectiveListNode; _semicolonNode = semicolonNode; }
public TryFinallyNode(Token tryKeywordNode, ListNode<DelimitedItemNode<AstNode>> tryStatementListNode, Token finallyKeywordNode, ListNode<DelimitedItemNode<AstNode>> finallyStatementListNode, Token endKeywordNode) { _tryKeywordNode = tryKeywordNode; _tryStatementListNode = tryStatementListNode; _finallyKeywordNode = finallyKeywordNode; _finallyStatementListNode = finallyStatementListNode; _endKeywordNode = endKeywordNode; }
private IEnumerable <Token> HandleCompilerDirective(Stack <IfDefTruth> ifDefStack, Token token) { string directive = token.ParsedText; string firstWord = FirstWordOf(directive); string parameter = directive.Substring(firstWord.Length).Trim(); switch (GetDirectiveType(firstWord)) { case DirectiveType.Unrecognized: if (ifDefStack.Peek() == IfDefTruth.True) { throw new LexException("Unrecognized compiler directive '" + firstWord + "'", token.Location); } break; case DirectiveType.Ignored: break; case DirectiveType.PossibleInclude: if (parameter.StartsWith("-") || parameter.StartsWith("+")) { // $I = $IOCHECKS. Ignore it. break; } else { // $I = $INCLUDE. Handle it. goto case DirectiveType.Include; } case DirectiveType.Include: IEnumerable <Token> sourceTokens = GetSourceTokensForInclude(token, parameter); IEnumerable <Token> filteredTokens = Filter(ifDefStack, sourceTokens); foreach (Token newToken in filteredTokens) { yield return(newToken); } break; case DirectiveType.Define: if (ifDefStack.Peek() == IfDefTruth.True) { _compilerDefines.DefineSymbol(parameter); } break; case DirectiveType.Undefine: if (ifDefStack.Peek() == IfDefTruth.True) { _compilerDefines.UndefineSymbol(parameter); } break; case DirectiveType.If: HandleIf(ifDefStack, directive, token.Location); break; case DirectiveType.Else: HandleElse(ifDefStack); break; case DirectiveType.ElseIf: HandleElseIf(ifDefStack, directive, token.Location); break; case DirectiveType.EndIf: ifDefStack.Pop(); break; } }
private IEnumerable<Token> GetSourceTokensForInclude(Token token, string baseName) { string currentDirectory = token.Location.Directory; string fileName = _fileLoader.ExpandFileName(currentDirectory, baseName); string source = _fileLoader.Load(fileName); Lexer lexer = new Lexer(source, fileName); return lexer.Tokens; }
public TypeHelperNode(Token typeKeywordNode, Token helperSemikeywordNode, Token openParenthesisNode, AstNode baseHelperTypeNode, Token closeParenthesisNode, Token forKeywordNode, AstNode typeNode, ListNode<VisibilitySectionNode> contentListNode, Token endKeywordNode) { _typeKeywordNode = typeKeywordNode; _helperSemikeywordNode = helperSemikeywordNode; _openParenthesisNode = openParenthesisNode; _baseHelperTypeNode = baseHelperTypeNode; _closeParenthesisNode = closeParenthesisNode; _forKeywordNode = forKeywordNode; _typeNode = typeNode; _contentListNode = contentListNode; _endKeywordNode = endKeywordNode; }
public TypeSectionNode(Token typeKeywordNode, ListNode<AstNode> typeListNode) { _typeKeywordNode = typeKeywordNode; _typeListNode = typeListNode; }
public VariantSectionNode(Token caseKeywordNode, Token nameNode, Token colonNode, AstNode typeNode, Token ofKeywordNode, ListNode<VariantGroupNode> variantGroupListNode) { _caseKeywordNode = caseKeywordNode; _nameNode = nameNode; _colonNode = colonNode; _typeNode = typeNode; _ofKeywordNode = ofKeywordNode; _variantGroupListNode = variantGroupListNode; }
public CaseStatementNode(Token caseKeywordNode, AstNode expressionNode, Token ofKeywordNode, ListNode<CaseSelectorNode> selectorListNode, Token elseKeywordNode, ListNode<DelimitedItemNode<AstNode>> elseStatementListNode, Token endKeywordNode) { _caseKeywordNode = caseKeywordNode; _expressionNode = expressionNode; _ofKeywordNode = ofKeywordNode; _selectorListNode = selectorListNode; _elseKeywordNode = elseKeywordNode; _elseStatementListNode = elseStatementListNode; _endKeywordNode = endKeywordNode; }
public VisibilityNode(Token strictSemikeywordNode, Token visibilityKeywordNode) { _strictSemikeywordNode = strictSemikeywordNode; _visibilityKeywordNode = visibilityKeywordNode; }
public UnaryOperationNode(Token operatorNode, AstNode operandNode) { _operatorNode = operatorNode; _operandNode = operandNode; }
public WithStatementNode(Token withKeywordNode, ListNode<DelimitedItemNode<AstNode>> expressionListNode, Token doKeywordNode, AstNode statementNode) { _withKeywordNode = withKeywordNode; _expressionListNode = expressionListNode; _doKeywordNode = doKeywordNode; _statementNode = statementNode; }
public UnitNode(Token unitKeywordNode, Token unitNameNode, ListNode<Token> portabilityDirectiveListNode, Token semicolonNode, UnitSectionNode interfaceSectionNode, UnitSectionNode implementationSectionNode, InitSectionNode initSectionNode, Token dotNode) { _unitKeywordNode = unitKeywordNode; _unitNameNode = unitNameNode; _portabilityDirectiveListNode = portabilityDirectiveListNode; _semicolonNode = semicolonNode; _interfaceSectionNode = interfaceSectionNode; _implementationSectionNode = implementationSectionNode; _initSectionNode = initSectionNode; _dotNode = dotNode; }
public ClassTypeNode(Token classKeywordNode, Token dispositionNode, Token openParenthesisNode, ListNode<DelimitedItemNode<AstNode>> inheritanceListNode, Token closeParenthesisNode, ListNode<VisibilitySectionNode> contentListNode, Token endKeywordNode) { _classKeywordNode = classKeywordNode; _dispositionNode = dispositionNode; _openParenthesisNode = openParenthesisNode; _inheritanceListNode = inheritanceListNode; _closeParenthesisNode = closeParenthesisNode; _contentListNode = contentListNode; _endKeywordNode = endKeywordNode; }
public UnitSectionNode(Token headerKeywordNode, UsesClauseNode usesClauseNode, ListNode<AstNode> contentListNode) { _headerKeywordNode = headerKeywordNode; _usesClauseNode = usesClauseNode; _contentListNode = contentListNode; }
public ConstantListNode(Token openParenthesisNode, ListNode<DelimitedItemNode<AstNode>> itemListNode, Token closeParenthesisNode) { _openParenthesisNode = openParenthesisNode; _itemListNode = itemListNode; _closeParenthesisNode = closeParenthesisNode; }
public UsedUnitNode(AstNode nameNode, Token inKeywordNode, Token fileNameNode) { _nameNode = nameNode; _inKeywordNode = inKeywordNode; _fileNameNode = fileNameNode; }
public virtual void VisitDelimitedItemNode(AstNode node, AstNode item, Token delimiter) { Visit(item); Visit(delimiter); }
public UsesClauseNode(Token usesKeywordNode, ListNode<DelimitedItemNode<UsedUnitNode>> unitListNode, Token semicolonNode) { _usesKeywordNode = usesKeywordNode; _unitListNode = unitListNode; _semicolonNode = semicolonNode; }
public Frame(Token token) { _token = token; }
public VarDeclNode(ListNode<DelimitedItemNode<Token>> nameListNode, Token colonNode, AstNode typeNode, ListNode<Token> firstPortabilityDirectiveListNode, Token absoluteSemikeywordNode, AstNode absoluteAddressNode, Token equalSignNode, AstNode valueNode, ListNode<Token> secondPortabilityDirectiveListNode, Token semicolonNode) { _nameListNode = nameListNode; _colonNode = colonNode; _typeNode = typeNode; _firstPortabilityDirectiveListNode = firstPortabilityDirectiveListNode; _absoluteSemikeywordNode = absoluteSemikeywordNode; _absoluteAddressNode = absoluteAddressNode; _equalSignNode = equalSignNode; _valueNode = valueNode; _secondPortabilityDirectiveListNode = secondPortabilityDirectiveListNode; _semicolonNode = semicolonNode; }
private IEnumerable<Token> HandleCompilerDirective(Stack<IfDefTruth> ifDefStack, Token token) { string directive = token.ParsedText; string firstWord = FirstWordOf(directive); string parameter = directive.Substring(firstWord.Length).Trim(); switch (GetDirectiveType(firstWord)) { case DirectiveType.Unrecognized: if (ifDefStack.Peek() == IfDefTruth.True) { throw new LexException("Unrecognized compiler directive '" + firstWord + "'", token.Location); } break; case DirectiveType.Ignored: break; case DirectiveType.PossibleInclude: if (parameter.StartsWith("-") || parameter.StartsWith("+")) { // $I = $IOCHECKS. Ignore it. break; } else { // $I = $INCLUDE. Handle it. goto case DirectiveType.Include; } case DirectiveType.Include: IEnumerable<Token> sourceTokens = GetSourceTokensForInclude(token, parameter); IEnumerable<Token> filteredTokens = Filter(ifDefStack, sourceTokens); foreach (Token newToken in filteredTokens) yield return newToken; break; case DirectiveType.Define: if (ifDefStack.Peek() == IfDefTruth.True) _compilerDefines.DefineSymbol(parameter); break; case DirectiveType.Undefine: if (ifDefStack.Peek() == IfDefTruth.True) _compilerDefines.UndefineSymbol(parameter); break; case DirectiveType.If: HandleIf(ifDefStack, directive, token.Location); break; case DirectiveType.Else: HandleElse(ifDefStack); break; case DirectiveType.ElseIf: HandleElseIf(ifDefStack, directive, token.Location); break; case DirectiveType.EndIf: ifDefStack.Pop(); break; } }