diff --git a/internal/pure/migration.go b/internal/pure/migration.go index 6fecb0fbb..b6afb1804 100644 --- a/internal/pure/migration.go +++ b/internal/pure/migration.go @@ -170,14 +170,20 @@ outer: _ = getBB(typ.PR.Begin.FileName(), typ.PR.Begin.FileContent()) } for _, f := range k.filesTL1 { - for _, typ := range f.Combinators() { - bb := getBB(typ.PR.Begin.FileName(), "") + bb := getBB(f.FileName, "") + for _, cs := range f.CS { + if cs.C == nil { + bb.WriteString(cs.S.String()) + continue + } + typ := cs.C //bb.WriteString(typ.SectionPR.Begin.FileContent()[typ.SectionPR.Begin.Offset():typ.SectionPR.End.Offset()]) if _, ok := migrateNames[typ.Construct.Name]; !ok { bb.WriteString(typ.AllPR.Begin.FileContent()[typ.AllPR.Begin.Offset():typ.AllPR.End.Offset()]) continue } } + bb.WriteString(f.CommentAfter) } // check there will be no references to TL2 combinators from TL1 combinators refErrList, err := k.findTL1toTL2References(migrateTips) diff --git a/internal/tlast/tlparser.go b/internal/tlast/tlparser.go index 7a6e67a05..4c0a91227 100644 --- a/internal/tlast/tlparser.go +++ b/internal/tlast/tlparser.go @@ -145,12 +145,20 @@ type Section struct { IsFunctions bool // otherwise, types } +func (s Section) String() string { + if s.IsFunctions { + return s.CommentBefore + "---functions---" + } + return s.CommentBefore + "---types---" +} + type CombinatorOrSection struct { C *Combinator // if !nil, this is combinator S Section // otherwise section } type TL struct { + FileName string CS []CombinatorOrSection CommentAfter string } diff --git a/internal/tlast/tlparser_code.go b/internal/tlast/tlparser_code.go index 917b562ba..6557871d6 100644 --- a/internal/tlast/tlparser_code.go +++ b/internal/tlast/tlparser_code.go @@ -648,7 +648,7 @@ func ParseTLFile(str, file string, opts LexerOptions) (*TL, error) { } functionSection := false - res := &TL{} + res := &TL{FileName: file} orderIndex := 0 rest := tokenIterator{tokens: allTokens}