Ejemplo n.º 1
0
        public override bool Parse(ParseContext context, IAstNode parent) {
            if (context.Tokens.CurrentToken.TokenType == RTokenType.Comma) {
                this.Comma = RParser.ParseToken(context, this);
            }

            return base.Parse(context, parent);
        }
Ejemplo n.º 2
0
        public override bool Parse(ParseContext context, IAstNode parent) {
            foreach (RToken t in Tokens) {
                TokenNode n = new TokenNode(t);
                n.Parent = this;
            }

            return base.Parse(context, parent);
        }
Ejemplo n.º 3
0
        protected bool ParseSemicolon(ParseContext context, IAstNode parent) {
            if (!context.Tokens.IsEndOfStream()) {
                if (!context.Tokens.IsLineBreakAfter(context.TextProvider, context.Tokens.Position - 1)) {
                    if (context.Tokens.CurrentToken.TokenType == RTokenType.Semicolon) {
                        this.Semicolon = RParser.ParseToken(context, this);
                    } else {
                        context.AddError(new ParseError(ParseErrorType.UnexpectedToken, ErrorLocation.Token, context.Tokens.CurrentToken));
                        return false;
                    }
                }
            }

            return true;
        }
        public override bool Parse(ParseContext context, IAstNode parent) {
            Debug.Assert(context.Tokens.CurrentToken.TokenType == RTokenType.Keyword);

            this.Keyword = RParser.ParseKeyword(context, this);
            this.Text = context.TextProvider.GetText(this.Keyword);

            bool result = base.Parse(context, parent);

            if (context.Tokens.CurrentToken.TokenType == RTokenType.Semicolon) {
                this.Semicolon = RParser.ParseToken(context, this);
            }

            return result;
        }
Ejemplo n.º 5
0
        public override bool Parse(ParseContext context, IAstNode parent) {
            Debug.Assert(context.Tokens.CurrentToken.TokenType == RTokenType.Operator);

            OperatorType = TokenOperator.GetOperatorType(context.TextProvider.GetText(context.Tokens.CurrentToken));
            OperatorToken = RParser.ParseToken(context, this);
            Associativity = OperatorAssociativity.GetAssociativity(OperatorType);

            // If operator is preceded by an operator, it is then unary
            // Look back two tokens since operator parsing already consumed its token.
            if (IsUnary || IsUnaryOperator(context.Tokens, context.TextProvider, OperatorType, -2)) {
                OperatorType = Operator.GetUnaryForm(OperatorType);
                IsUnary = true;
                Associativity = Associativity.Right;
            }
            return base.Parse(context, parent);
        }
Ejemplo n.º 6
0
        public override bool Parse(ParseContext context, IAstNode parent) {
            TokenStream<RToken> tokens = context.Tokens;

            Debug.Assert(tokens.CurrentToken.TokenType == RTokenType.OpenBrace);
            this.OpenBrace = RParser.ParseToken(context, this);

            this.Content = new Expression(inGroup: true);
            this.Content.Parse(context, this);

            if (tokens.CurrentToken.TokenType == RTokenType.CloseBrace) {
                this.CloseBrace = RParser.ParseToken(context, this);
            } else {
                context.AddError(new MissingItemParseError(ParseErrorType.CloseBraceExpected, tokens.PreviousToken));
            }

            return base.Parse(context, parent);
        }
Ejemplo n.º 7
0
        public override bool Parse(ParseContext context, IAstNode parent) {
            TokenStream<RToken> tokens = context.Tokens;

            Debug.Assert(tokens.CurrentToken.TokenType == RTokenType.OpenSquareBracket ||
                         tokens.CurrentToken.TokenType == RTokenType.OpenDoubleSquareBracket);

            this.LeftBrackets = RParser.ParseToken(context, this);
            RTokenType terminatingTokenType = RParser.GetTerminatingTokenType(this.LeftBrackets.Token.TokenType);

            this.Arguments = new ArgumentList(terminatingTokenType);
            this.Arguments.Parse(context, this);

            if (tokens.CurrentToken.TokenType == terminatingTokenType) {
                this.RightBrackets = RParser.ParseToken(context, this);
            } else {
                context.AddError(new MissingItemParseError(ParseErrorType.CloseSquareBracketExpected, tokens.PreviousToken));
            }

            return base.Parse(context, parent);
        }
        public override bool Parse(ParseContext context, IAstNode parent) {
            if (ParseKeyword(context, parent)) {
                this.OpenBrace = RParser.ParseOpenBraceSequence(context, this);
                if (this.OpenBrace != null) {
                    this.ParseExpression(context, this);

                    // Even if expression is broken but we are at 
                    // the closing brace we want to recover and continue.

                    if (context.Tokens.CurrentToken.TokenType == Tokens.RTokenType.CloseBrace) {
                        this.CloseBrace = RParser.ParseCloseBraceSequence(context, this);
                        if (this.CloseBrace != null) {
                            this.Parent = parent;
                            return true;
                        }
                    }
                }
            }

            return false;
        }
        public override bool Parse(ParseContext context, IAstNode parent) {
            if (ParseKeyword(context, this)) {
                this.OpenBrace = RParser.ParseOpenBraceSequence(context, this);
                if (this.OpenBrace != null) {
                    RToken token = context.Tokens.CurrentToken;

                    if (token.TokenType == RTokenType.Identifier || token.TokenType == RTokenType.String) {
                        this.Identifier = RParser.ParseToken(context, this);

                        this.CloseBrace = RParser.ParseCloseBraceSequence(context, this);
                        if (this.CloseBrace != null) {
                            this.Parent = parent;
                            return true;
                        }
                    } else {
                        context.AddError(new ParseError(ParseErrorType.IndentifierExpected, ErrorLocation.Token, context.Tokens.CurrentToken));
                    }
                }
            }

            return false;
        }
Ejemplo n.º 10
0
 public override bool Parse(ParseContext context, IAstNode parent)
 {
     this.Semicolon = RParser.ParseToken(context, this);
     return(base.Parse(context, parent));
 }
Ejemplo n.º 11
0
 public MatchTree(TokenNode matchTreeRoot, string language, double totalPossibleScore)
 {
     MatchTreeRoot = matchTreeRoot;
     Language = language;
     TotalPossibleScore = totalPossibleScore;
 }
Ejemplo n.º 12
0
 public ArrayReferenceSyntax(TokenNode idNode, TokenNode openBracketNode, NewExpressionSyntax expressionNode, TokenNode closeBracketNode)
     : base(idNode, openBracketNode, expressionNode, closeBracketNode)
 {
     _id         = idNode ?? throw new ArgumentNullException(nameof(idNode));
     _open       = openBracketNode ?? throw new ArgumentNullException(nameof(openBracketNode));
     _expression = expressionNode ?? throw new ArgumentNullException(nameof(expressionNode));
     _close      = closeBracketNode ?? throw new ArgumentNullException(nameof(closeBracketNode));
 }
Ejemplo n.º 13
0
 public ExitStatementSyntax(TokenNode exitNode, NewExpressionSyntax expressionNode)
     : base(exitNode, expressionNode)
 {
     _exit       = exitNode ?? throw new ArgumentNullException(nameof(exitNode));
     _expression = expressionNode ?? throw new ArgumentNullException(nameof(exitNode));
 }
Ejemplo n.º 14
0
        public static Microsoft.CodeAnalysis.CSharp.SyntaxKind TranspileUnaryOperator(this TokenNode tokenNode)
        {
            _ = tokenNode ?? throw new ArgumentNullException(nameof(tokenNode));

            switch (tokenNode.TokenType)
            {
            case SyntaxTokenType.PlusOperator: return(Microsoft.CodeAnalysis.CSharp.SyntaxKind.UnaryPlusExpression);

            case SyntaxTokenType.MinusOperator: return(Microsoft.CodeAnalysis.CSharp.SyntaxKind.UnaryMinusExpression);

            case SyntaxTokenType.NotOperator: return(Microsoft.CodeAnalysis.CSharp.SyntaxKind.LogicalNotExpression);

            default:
                throw new ArgumentException($"Cannot transpile token of type {tokenNode.TokenType} to an operator of a unary expression.");
            }
        }
Ejemplo n.º 15
0
 public TypeSyntax(TokenNode typeNode)
     : base(typeNode)
 {
     _type = typeNode ?? throw new ArgumentNullException(nameof(typeNode));
 }
Ejemplo n.º 16
0
 public ExpressionSyntax(TokenNode idNode)
     : base(idNode)
 {
     _id = idNode ?? throw new ArgumentNullException(nameof(idNode));
 }
Ejemplo n.º 17
0
 public TypeIdentifierSyntax(TokenNode nothingNode)
     : base(nothingNode)
 {
     _nothing = nothingNode ?? throw new ArgumentNullException(nameof(nothingNode));
 }
Ejemplo n.º 18
0
 public IfStatementSyntax(TokenNode ifNode, NewExpressionSyntax expressionNode, TokenNode thenNode, LineDelimiterSyntax eolNode, StatementListSyntax statementListNode, EmptyNode emptyElseClauseNode, TokenNode endifNode)
     : base(ifNode, expressionNode, thenNode, eolNode, statementListNode, emptyElseClauseNode, endifNode)
 {
     _if              = ifNode ?? throw new ArgumentNullException(nameof(ifNode));
     _expression      = expressionNode ?? throw new ArgumentNullException(nameof(expressionNode));
     _then            = thenNode ?? throw new ArgumentNullException(nameof(thenNode));
     _eol             = eolNode ?? throw new ArgumentNullException(nameof(eolNode));
     _statements      = statementListNode ?? throw new ArgumentNullException(nameof(statementListNode));
     _emptyElseClause = emptyElseClauseNode ?? throw new ArgumentNullException(nameof(emptyElseClauseNode));
     _endif           = endifNode ?? throw new ArgumentNullException(nameof(endifNode));
 }
Ejemplo n.º 19
0
 public FunctionReferenceSyntax(TokenNode functionNode, TokenNode idNode)
     : base(functionNode, idNode)
 {
     _function = functionNode ?? throw new ArgumentNullException(nameof(functionNode));
     _id       = idNode ?? throw new ArgumentNullException(nameof(idNode));
 }
Ejemplo n.º 20
0
 public ElseifSyntax(TokenNode elseifNode, NewExpressionSyntax expressionNode, TokenNode thenNode, LineDelimiterSyntax eolNode, StatementListSyntax statementsNode, ElseClauseSyntax elseClauseNode)
     : base(elseifNode, expressionNode, thenNode, eolNode, statementsNode, elseClauseNode)
 {
     _elseif     = elseifNode ?? throw new ArgumentNullException(nameof(elseifNode));
     _expression = expressionNode ?? throw new ArgumentNullException(nameof(expressionNode));
     _then       = thenNode ?? throw new ArgumentNullException(nameof(thenNode));
     _eol        = eolNode ?? throw new ArgumentNullException(nameof(eolNode));
     _statements = statementsNode ?? throw new ArgumentNullException(nameof(statementsNode));
     _elseClause = elseClauseNode ?? throw new ArgumentNullException(nameof(elseClauseNode));
 }
Ejemplo n.º 21
0
 private void AddNode(TreeIter parent, TokenNode token)
 {
     parent = store.AppendValues(parent, "token", token);
     AddNode(parent, token.Body);
 }
Ejemplo n.º 22
0
 public override bool Parse(ParseContext context, IAstNode parent) {
     this.Semicolon = RParser.ParseToken(context, this);
     return base.Parse(context, parent);
 }
Ejemplo n.º 23
0
 public FileSyntax(LineDelimiterSyntax eolNode, DeclarationListSyntax declarationsNode, FunctionListSyntax functionsNode, TokenNode endOfFileNode)
     : base(eolNode, declarationsNode, functionsNode, endOfFileNode)
 {
     _eol       = eolNode ?? throw new ArgumentNullException(nameof(eolNode));
     _declrs    = declarationsNode ?? throw new ArgumentNullException(nameof(declarationsNode));
     _functions = functionsNode ?? throw new ArgumentNullException(nameof(functionsNode));
     _eof       = endOfFileNode ?? throw new ArgumentNullException(nameof(endOfFileNode));
 }
Ejemplo n.º 24
0
 public CommaSeparatedExpressionSyntax(TokenNode commaNode, NewExpressionSyntax expressionNode)
     : base(commaNode, expressionNode)
 {
     _comma      = commaNode ?? throw new ArgumentNullException(nameof(commaNode));
     _expression = expressionNode ?? throw new ArgumentNullException(nameof(expressionNode));
 }
Ejemplo n.º 25
0
 public FileSyntax(EmptyNode emptyNode, DeclarationListSyntax declarationsNode, FunctionListSyntax functionsNode, TokenNode endOfFileNode)
     : base(emptyNode, declarationsNode, functionsNode, endOfFileNode)
 {
     _empty     = emptyNode ?? throw new ArgumentNullException(nameof(emptyNode));
     _declrs    = declarationsNode ?? throw new ArgumentNullException(nameof(declarationsNode));
     _functions = functionsNode ?? throw new ArgumentNullException(nameof(functionsNode));
     _eof       = endOfFileNode ?? throw new ArgumentNullException(nameof(endOfFileNode));
 }
Ejemplo n.º 26
0
 public ParenthesizedExpressionSyntax(TokenNode openNode, NewExpressionSyntax expressionNode, TokenNode closeNode)
     : base(openNode, expressionNode, closeNode)
 {
     _open       = openNode ?? throw new ArgumentNullException(nameof(openNode));
     _expression = expressionNode ?? throw new ArgumentNullException(nameof(expressionNode));
     _close      = closeNode ?? throw new ArgumentNullException(nameof(closeNode));
 }
Ejemplo n.º 27
0
        public static Microsoft.CodeAnalysis.CSharp.SyntaxKind TranspileBinaryOperator(this TokenNode tokenNode)
        {
            _ = tokenNode ?? throw new ArgumentNullException(nameof(tokenNode));

            switch (tokenNode.TokenType)
            {
            case SyntaxTokenType.PlusOperator: return(Microsoft.CodeAnalysis.CSharp.SyntaxKind.AddExpression);

            case SyntaxTokenType.MinusOperator: return(Microsoft.CodeAnalysis.CSharp.SyntaxKind.SubtractExpression);

            case SyntaxTokenType.MultiplicationOperator: return(Microsoft.CodeAnalysis.CSharp.SyntaxKind.MultiplyExpression);

            case SyntaxTokenType.DivisionOperator: return(Microsoft.CodeAnalysis.CSharp.SyntaxKind.DivideExpression);

            case SyntaxTokenType.GreaterThanOperator: return(Microsoft.CodeAnalysis.CSharp.SyntaxKind.GreaterThanExpression);

            case SyntaxTokenType.LessThanOperator: return(Microsoft.CodeAnalysis.CSharp.SyntaxKind.LessThanExpression);

            case SyntaxTokenType.EqualityOperator: return(Microsoft.CodeAnalysis.CSharp.SyntaxKind.EqualsExpression);      // rename EqualsOperator?

            case SyntaxTokenType.UnequalityOperator: return(Microsoft.CodeAnalysis.CSharp.SyntaxKind.NotEqualsExpression); // rename NotEqualsOperator?

            case SyntaxTokenType.GreaterOrEqualOperator: return(Microsoft.CodeAnalysis.CSharp.SyntaxKind.GreaterThanOrEqualExpression);

            case SyntaxTokenType.LessOrEqualOperator: return(Microsoft.CodeAnalysis.CSharp.SyntaxKind.LessThanOrEqualExpression);

            case SyntaxTokenType.AndOperator: return(Microsoft.CodeAnalysis.CSharp.SyntaxKind.LogicalAndExpression);

            case SyntaxTokenType.OrOperator: return(Microsoft.CodeAnalysis.CSharp.SyntaxKind.LogicalOrExpression);

            default:
                throw new ArgumentException($"Cannot transpile token of type {tokenNode.TokenType} to an operator of a binary expression.");
            }
        }
Ejemplo n.º 28
0
 public IntegerSyntax(TokenNode tokenNode)
     : base(tokenNode)
 {
     _token = tokenNode ?? throw new ArgumentNullException(nameof(tokenNode));
 }
 public CommaSeparatedTypeReferenceSyntax(TokenNode commaNode, TypeReferenceSyntax typeReferenceNode)
     : base(commaNode, typeReferenceNode)
 {
     _comma = commaNode ?? throw new ArgumentNullException(nameof(commaNode));
     _type  = typeReferenceNode ?? throw new ArgumentNullException(nameof(typeReferenceNode));
 }
Ejemplo n.º 30
0
 public FunctionSyntax(EmptyNode emptyNode, TokenNode functionNode, FunctionDeclarationSyntax declarationNode, LineDelimiterSyntax eolNode1, LocalVariableListSyntax localVariableListNode, StatementListSyntax statementListNode, TokenNode endfunctionNode, LineDelimiterSyntax eolNode2)
     : base(emptyNode, functionNode, declarationNode, eolNode1, localVariableListNode, statementListNode, endfunctionNode, eolNode2)
 {
     _empty       = emptyNode ?? throw new ArgumentNullException(nameof(emptyNode));
     _function    = functionNode ?? throw new ArgumentNullException(nameof(functionNode));
     _declr       = declarationNode ?? throw new ArgumentNullException(nameof(declarationNode));
     _eol1        = eolNode1 ?? throw new ArgumentNullException(nameof(eolNode1));
     _locals      = localVariableListNode ?? throw new ArgumentNullException(nameof(localVariableListNode));
     _statements  = statementListNode ?? throw new ArgumentNullException(nameof(statementListNode));
     _endfunction = endfunctionNode ?? throw new ArgumentNullException(nameof(endfunctionNode));
     _eol2        = eolNode2 ?? throw new ArgumentNullException(nameof(eolNode2));
 }
Ejemplo n.º 31
0
 public TypeReferenceSyntax(TypeSyntax typeNode, TokenNode idNode)
     : base(typeNode, idNode)
 {
     _type = typeNode ?? throw new ArgumentNullException(nameof(typeNode));
     _id   = idNode ?? throw new ArgumentNullException(nameof(idNode));
 }
Ejemplo n.º 32
0
 public FunctionCallSyntax(TokenNode idNode, TokenNode openParensNode, ArgumentListSyntax argumentListNode, TokenNode closeParensNode)
     : base(idNode, openParensNode, argumentListNode, closeParensNode)
 {
     _id    = idNode ?? throw new ArgumentNullException(nameof(idNode));
     _open  = openParensNode ?? throw new ArgumentNullException(nameof(openParensNode));
     _args  = argumentListNode ?? throw new ArgumentNullException(nameof(argumentListNode));
     _close = closeParensNode ?? throw new ArgumentNullException(nameof(closeParensNode));
 }
Ejemplo n.º 33
0
 public GlobalsBlockSyntax(TokenNode globalsNode, LineDelimiterSyntax eolNode, GlobalsDeclarationListSyntax globalsListNode, TokenNode endglobalsNode)
     : base(globalsNode, eolNode, globalsListNode, endglobalsNode)
 {
     _globals     = globalsNode ?? throw new ArgumentNullException(nameof(globalsNode));
     _eol         = eolNode ?? throw new ArgumentNullException(nameof(eolNode));
     _globalsList = globalsListNode ?? throw new ArgumentNullException(nameof(globalsListNode));
     _endglobals  = endglobalsNode ?? throw new ArgumentNullException(nameof(endglobalsNode));
 }
Ejemplo n.º 34
0
 internal TokenNode(TokenNode original) : base(original)
 {
     this.ValueProvider = original.ValueProvider;
     this.Format        = original.Format;
 }
Ejemplo n.º 35
0
 public LoopStatementSyntax(TokenNode loopNode, LineDelimiterSyntax eolNode, StatementListSyntax statementListNode, TokenNode endloopNode)
     : base(loopNode, eolNode, statementListNode, endloopNode)
 {
     _loop       = loopNode ?? throw new ArgumentNullException(nameof(loopNode));
     _eol        = eolNode ?? throw new ArgumentNullException(nameof(eolNode));
     _statements = statementListNode ?? throw new ArgumentNullException(nameof(statementListNode));
     _endloop    = endloopNode ?? throw new ArgumentNullException(nameof(endloopNode));
 }
Ejemplo n.º 36
0
 public CallStatementSyntax(TokenNode callNode, TokenNode idNode, TokenNode openParensNode, EmptyNode emptyArgumentListNode, TokenNode closeParensNode)
     : base(callNode, idNode, openParensNode, emptyArgumentListNode, closeParensNode)
 {
     _call      = callNode ?? throw new ArgumentNullException(nameof(callNode));
     _id        = idNode ?? throw new ArgumentNullException(nameof(idNode));
     _open      = openParensNode ?? throw new ArgumentNullException(nameof(openParensNode));
     _emptyArgs = emptyArgumentListNode ?? throw new ArgumentNullException(nameof(emptyArgumentListNode));
     _close     = closeParensNode ?? throw new ArgumentNullException(nameof(closeParensNode));
 }
Ejemplo n.º 37
0
 public EqualsValueClauseSyntax(TokenNode assignmentNode, NewExpressionSyntax expressionNode)
     : base(assignmentNode, expressionNode)
 {
     _ass        = assignmentNode ?? throw new ArgumentNullException(nameof(assignmentNode));
     _expression = expressionNode ?? throw new ArgumentNullException(nameof(expressionNode));
 }
Ejemplo n.º 38
0
 public EndOfLineSyntax(TokenNode newlineNode)
     : base(newlineNode)
 {
     _newline = newlineNode ?? throw new ArgumentNullException(nameof(newlineNode));
 }
Ejemplo n.º 39
0
 public ReturnStatementSyntax(TokenNode returnNode, NewExpressionSyntax expressionNode)
     : base(returnNode, expressionNode)
 {
     _return     = returnNode ?? throw new ArgumentNullException(nameof(returnNode));
     _expression = expressionNode ?? throw new ArgumentNullException(nameof(expressionNode));
 }
Ejemplo n.º 40
0
 public FunctionDeclarationSyntax(TokenNode idNode, TokenNode takesNodes, ParameterListReferenceSyntax parameterListNode, TokenNode returnsNode, TypeIdentifierSyntax returnTypeNode)
     : base(idNode, takesNodes, parameterListNode, returnsNode, returnTypeNode)
 {
     _id         = idNode ?? throw new ArgumentNullException(nameof(idNode));
     _takes      = takesNodes ?? throw new ArgumentNullException(nameof(takesNodes));
     _params     = parameterListNode ?? throw new ArgumentNullException(nameof(parameterListNode));
     _returns    = returnsNode ?? throw new ArgumentNullException(nameof(returnsNode));
     _returnType = returnTypeNode ?? throw new ArgumentNullException(nameof(returnTypeNode));
 }
Ejemplo n.º 41
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void extract(org.maltparser.core.syntaxgraph.PhraseStructure phraseStructure, int begin, int end, org.maltparser.core.syntaxgraph.node.PhraseStructureNode parent) throws org.maltparser.core.exception.MaltChainedException
        private void extract(PhraseStructure phraseStructure, int begin, int end, PhraseStructureNode parent)
        {
            SymbolTableHandler symbolTables = phraseStructure.SymbolTables;
            int index = -1;

            for (int i = begin; i < end; i++)
            {
                if (input[i] == STARTING_BRACKET && (i == begin || input[i - 1] != '\\'))
                {
                    index = i;
                    break;
                }
            }
            if (index == -1)
            {
                TokenNode t = phraseStructure.AddTokenNode(terminalCounter);
                if (t == null)
                {
                    close();
                    throw new MaltChainedException("Bracket Reader error: could not create a terminal node. ");
                }

                terminalCounter++;
                Edge.Edge e = null;

                if (parent != null)
                {
                    e = phraseStructure.addPhraseStructureEdge(parent, (PhraseStructureNode)t);
                }
                else
                {
                    close();
                    throw new MaltChainedException("Bracket Reader error: could not find the parent node. ");
                }

                int start = begin;

                IEnumerator <string> inputColumnsIterator      = inputColumns.Keys.GetEnumerator();
                IEnumerator <string> edgeLabelsColumnsIterator = edgeLabelColumns.Keys.GetEnumerator();
                bool noneNode   = false;
                bool edgeLabels = false;
                for (int i = begin; i < end; i++)
                {
                    if (input[i] == EDGELABEL_SEPARATOR || (input[i] == INPUT_SEPARATOR && (i == begin || input[i - 1] != '\\')) || i == end - 1)
                    {
                        if (i == begin && input[i] == EDGELABEL_SEPARATOR)
                        {
                            noneNode = true;
                        }
                        else if (start == begin)
                        {
                            if ((noneNode && input[i] != EDGELABEL_SEPARATOR) || !noneNode)
                            {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                                if (inputColumnsIterator.hasNext())
                                {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                                    t.addLabel(symbolTables.getSymbolTable(inputColumns[inputColumnsIterator.next()].Name), decodeString((i == end - 1)?input.substring(start, end - start):input.substring(start, i - start)));
                                }
                                start = i + 1;
                                if (input[i] == EDGELABEL_SEPARATOR)
                                {
                                    edgeLabels = true;
                                }
                            }
                        }
                        else if (edgeLabels && e != null)
                        {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                            if (edgeLabelsColumnsIterator.hasNext())
                            {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                                e.addLabel(symbolTables.getSymbolTable(edgeLabelColumns[edgeLabelsColumnsIterator.next()].Name), (i == end - 1)?input.substring(start, end - start):input.substring(start, i - start));
                            }
                            start = i + 1;
                            if (input[i] == INPUT_SEPARATOR && (i == begin || input[i - 1] != '\\'))
                            {
                                edgeLabels = false;
                            }
                        }
                        else if (input[i] == EDGELABEL_SEPARATOR && i != end - 1 && (input[i + 1] != INPUT_SEPARATOR && (i == begin || input[i - 1] != '\\')))
                        {
                        }
                        else
                        {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                            if (inputColumnsIterator.hasNext())
                            {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                                t.addLabel(symbolTables.getSymbolTable(inputColumns[inputColumnsIterator.next()].Name), (i == end - 1)?input.substring(start, end - start):input.substring(start, i - start));
                            }
                            start = i + 1;
                        }
                    }
                }
            }
            else
            {
                PhraseStructureNode nt;
                Edge.Edge           e = null;
                if (parent == null)
                {
                    nt = phraseStructure.PhraseStructureRoot;
                }
                else
                {
                    nt = phraseStructure.addNonTerminalNode(nonTerminalCounter);
                    if (nt == null)
                    {
                        close();
                        throw new MaltChainedException("Bracket Reader error: could not create a nonterminal node. ");
                    }
                    nonTerminalCounter++;

                    e = phraseStructure.addPhraseStructureEdge(parent, nt);
                }
                IEnumerator <string> phraseLabelColumnsIterator = phraseLabelColumns.Keys.GetEnumerator();
                IEnumerator <string> edgeLabelsColumnsIterator  = edgeLabelColumns.Keys.GetEnumerator();
                int newbegin = begin;
                int start    = begin;

                for (int i = begin; i < index; i++)
                {
                    if (input[i] == EDGELABEL_SEPARATOR || i == index - 1)
                    {
                        if (start == newbegin)
                        {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                            if (phraseLabelColumnsIterator.hasNext())
                            {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                                nt.addLabel(symbolTables.getSymbolTable(phraseLabelColumns[phraseLabelColumnsIterator.next()].Name), (i == index - 1)?input.substring(start, index - start):input.substring(start, i - start));
                            }
                            start = i + 1;
                        }
                        else if (e != null)
                        {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                            if (edgeLabelsColumnsIterator.hasNext())
                            {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                                e.addLabel(symbolTables.getSymbolTable(edgeLabelColumns[edgeLabelsColumnsIterator.next()].Name), (i == index - 1)?input.substring(start, index - start):input.substring(start, i - start));
                            }
                            start = i + 1;
                        }
                    }
                    else if (input[i] == BLANK)
                    {
                        start++;
                        newbegin++;
                    }
                }

                bracketing(phraseStructure, index, end, nt);
            }
        }
Ejemplo n.º 42
0
 public override bool Parse(ParseContext context, IAstNode parent) {
     EllipsisToken = RParser.ParseToken(context, this);
     return base.Parse(context, parent);
 }