Beispiel #1
0
 // RelativeModuleName
 public override bool Walk(RelativeModuleName node)
 {
     return ShouldWalkWorker(node);
 }
Beispiel #2
0
        // relative_module: "."* module | "."+
        private ModuleName ParseRelativeModuleName()
        {
            var start = GetStart();

            int dotCount = 0;
            List<string> dotWhiteSpace = MakeWhiteSpaceList();
            for (; ; ) {
                if (MaybeEat(TokenKind.Dot)) {
                    if (dotWhiteSpace != null) {
                        dotWhiteSpace.Add(_tokenWhiteSpace);
                    }
                    dotCount++;
                } else if (MaybeEat(TokenKind.Ellipsis)) {
                    if (dotWhiteSpace != null) {
                        dotWhiteSpace.Add(_tokenWhiteSpace);
                        dotWhiteSpace.Add("");
                        dotWhiteSpace.Add("");
                    }
                    dotCount += 3;
                } else {
                    break;
                }
            }

            List<string> nameWhiteSpace = null;
            NameExpression[] names = EmptyNames;
            if (PeekToken() is NameToken) {
                names = ReadDottedName(out nameWhiteSpace);
            }

            ModuleName ret;
            if (dotCount > 0) {
                ret = new RelativeModuleName(names, dotCount);
                if (_verbatim) {
                    if (nameWhiteSpace != null) {
                        AddNamesWhiteSpace(ret, nameWhiteSpace.ToArray());
                    }
                    AddListWhiteSpace(ret, dotWhiteSpace.ToArray());
                }
            } else {
                if (names.Length == 0) {
                    ReportSyntaxError(_lookahead.Span.Start, _lookahead.Span.End, "missing module name");
                }
                ret = new ModuleName(names);
                if (nameWhiteSpace != null) {
                    AddNamesWhiteSpace(ret, nameWhiteSpace.ToArray());
                }
            }

            ret.SetLoc(start, GetEnd());
            return ret;
        }
Beispiel #3
0
 public override void PostWalk(RelativeModuleName node)
 {
     PostWalkWorker(node);
 }