├── .editorconfig ├── .gitattributes ├── .gitignore ├── .travis.yml ├── Core ├── .gitignore ├── AssemblyVersion.cs ├── Lib │ ├── Aga.Controls.dll │ ├── UpdateControls.Forms.XML │ ├── UpdateControls.Forms.dll │ ├── UpdateControls.dll │ └── UpdateControls.xml ├── License.txt ├── Loyc.Collections.nuspec ├── Loyc.Collections │ ├── ALists │ │ ├── AList.cd │ │ ├── AList.cs │ │ ├── AListBase.cs │ │ ├── AListIndexer.cs │ │ ├── AListInner.cs │ │ ├── AListInnerBase.cs │ │ ├── AListLeaf.cs │ │ ├── AListNode.cs │ │ ├── AListNodeObserver.cs │ │ ├── AListNodes.cd │ │ ├── BDictionary.cs │ │ ├── BList.cs │ │ ├── BListInner.cs │ │ ├── BListLeaf.cs │ │ ├── BMultiMap.cs │ │ ├── IAListTreeObserver.cs │ │ ├── IndexedAList.cs │ │ ├── SparseAList.cs │ │ └── SparseAListLeaf.cs │ ├── CG.cs │ ├── Heap.cs │ ├── InternalDArray.cs │ ├── Loyc.Collections.csproj │ ├── Loyc.Collections.net45.csproj │ ├── OpenSourceKey.snk │ ├── Other │ │ ├── ArrayOf4.cs │ │ ├── Bijection.cs │ │ ├── BloomFilterM64K2.cs │ │ ├── Co.cs │ │ ├── NestedEnumerator.cs │ │ └── SimpleCache.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Sets │ │ ├── InternalSet.cs │ │ ├── InternalSetV1.cs │ │ ├── InvertibleSet.cs │ │ ├── MMap.cs │ │ ├── MSet.cs │ │ ├── Map.cs │ │ └── Set.cs │ ├── TypeDictionaryWithBaseTypeLookups.cs │ └── VLists │ │ ├── Diagrams │ │ ├── ChangingPList.png │ │ ├── IdealVList.png │ │ ├── LinkedList.png │ │ ├── PathologicalVList.png │ │ ├── VListSharing1.png │ │ ├── VListSharing2.png │ │ ├── WList.png │ │ ├── WListImmutification.png │ │ └── WListRemutification.png │ │ ├── FVList.cs │ │ ├── FWList.cs │ │ ├── VList.cs │ │ ├── VListBlock.cs │ │ ├── VListBlockArray.cs │ │ ├── VListBlockOfTwo.cs │ │ ├── WList.cs │ │ └── WListBase.cs ├── Loyc.Essentials.nuspec ├── Loyc.Essentials │ ├── Collections │ │ ├── Adapters │ │ │ ├── ArraySlice.cs │ │ │ ├── BufferedSequence.cs │ │ │ ├── CollectionAsSource.cs │ │ │ ├── DictionaryAsSink.cs │ │ │ ├── ListAsListSource.cs │ │ │ ├── ListAsSink.cs │ │ │ ├── ListSlice.cs │ │ │ ├── ListSourceAsList.cs │ │ │ ├── ListSourceAsSparse.cs │ │ │ ├── NegList.cs │ │ │ ├── NegListSlice.cs │ │ │ ├── NegListSource.cs │ │ │ ├── ROLSlice.cs │ │ │ ├── ReadOnlyListAsListSource.cs │ │ │ ├── ReverseBinumerator.cs │ │ │ ├── ReversedList.cs │ │ │ ├── ReversedListSource.cs │ │ │ ├── SelectDictionaryFromKeys.cs │ │ │ ├── Slice.cs │ │ │ ├── SourceAsCollection.cs │ │ │ └── SparseListSourceSlice.cs │ │ ├── BaseClasses │ │ │ ├── CollectionWrapper.cs │ │ │ ├── DictionaryWrapper.cs │ │ │ ├── EnumeratorBase.cs │ │ │ ├── ListExBase.cs │ │ │ ├── ListSourceBase.cs │ │ │ ├── ListWrapper.cs │ │ │ ├── ReadOnlyCollectionBase.cs │ │ │ └── SetWrapper.cs │ │ ├── CollectionDebugView.cs │ │ ├── ExtensionMethods │ │ │ ├── DictionaryExt.cs │ │ │ ├── EnumerableExt.ecs │ │ │ ├── EnumerableExt.out.cs │ │ │ ├── ICollectionExt.cs │ │ │ ├── IPush, IPop.cs │ │ │ ├── LCExtensions.cs │ │ │ ├── LinqToLists.ecs │ │ │ ├── LinqToLists.out.cs │ │ │ ├── ListExt.cs │ │ │ └── Range.cs │ │ ├── HelperClasses │ │ │ ├── CollectionWithChangeEvents.cs │ │ │ ├── DictionaryWithChangeEvents.cs │ │ │ ├── EmptyArray.cs │ │ │ ├── EmptyEnumerator.cs │ │ │ ├── EmptyList.cs │ │ │ ├── ListWithChangeEvents.cs │ │ │ ├── NumRange.cs │ │ │ ├── RangeEnumerator.cs │ │ │ ├── Repeated.cs │ │ │ ├── ReverseComparer.cs │ │ │ ├── SelectCollection.ecs │ │ │ ├── SelectCollection.out.cs │ │ │ ├── SelectListSource.ecs │ │ │ └── SelectListSource.out.cs │ │ └── Implementations │ │ │ ├── DList.cs │ │ │ ├── InternalDList.cs │ │ │ ├── InternalList.cs │ │ │ ├── WeakKeyComparer.cs │ │ │ └── WeakKeyDictionary.cs │ ├── Compatibility │ │ └── WeakReference.cs │ ├── Loyc.Essentials.csproj │ ├── Loyc.Essentials.net45.csproj │ ├── MessageSinks │ │ ├── BasicSinks.cs │ │ ├── LogException.cs │ │ ├── LogMessage.cs │ │ ├── MessageHolder.cs │ │ ├── MessageSink.ecs │ │ ├── MessageSink.out.cs │ │ └── WrapperSinks.cs │ ├── OpenSourceKey.snk │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Strings │ │ ├── StringBuilderExt.cs │ │ └── StringExt.cs │ ├── Utilities │ │ ├── ByteArrayInString.cs │ │ ├── Extensions.cs │ │ ├── EzStopwatch.cs │ │ ├── G.cs │ │ ├── GRange.ecs │ │ ├── GRange.out.cs │ │ ├── HashTags.cs │ │ ├── Holder.cs │ │ ├── IoC.cs │ │ ├── MiniTest.cs │ │ ├── PrintHelpers.cs │ │ ├── RunTests.cs │ │ ├── SavedValue.cs │ │ ├── ThreadEx.cs │ │ ├── Triplet.cs │ │ ├── ValueComparer.cs │ │ └── WrapperBase.cs │ ├── app.config │ └── void.cs ├── Loyc.Interfaces.nuspec ├── Loyc.Interfaces │ ├── Collections │ │ ├── Disambiguation interfaces.cs │ │ ├── Extended interfaces.cs │ │ ├── IAutoCreatePool.cs │ │ ├── ICharSource.cs │ │ ├── ICollectionSource.cs │ │ ├── ICount.cs │ │ ├── IDictionaryEx.cs │ │ ├── IDictionarySource.cs │ │ ├── IListSource.cs │ │ ├── INegListSource.cs │ │ ├── INotifyListChanged.cs │ │ ├── INotifyListChanging.cs │ │ ├── IRanges.cs │ │ ├── ISetImm.cs │ │ ├── ISparseList.cs │ │ ├── ITuple.cs │ │ ├── New enumerators.cs │ │ ├── Other interfaces.cs │ │ ├── Queue interfaces.cs │ │ └── Sink interfaces.cs │ ├── Concrete │ │ ├── BaseDictionary.cs │ │ ├── Either.cs │ │ ├── EmptySourceFile.cs │ │ ├── Exceptions.cs │ │ ├── IndexRange.cs │ │ ├── KeyCollection.cs │ │ ├── ListChangeInfo.cs │ │ ├── Localize.cs │ │ ├── Maybe.cs │ │ ├── MemoizedTypeName.cs │ │ ├── NoValue.cs │ │ ├── Pair.cs │ │ ├── RangeEnumerator.cs │ │ ├── SavedThreadLocal.cs │ │ ├── ScratchBuffer.cs │ │ ├── SourcePos.cs │ │ ├── Symbol.cs │ │ ├── UString.cs │ │ ├── ValueCollection.cs │ │ └── WeakValueDictionary.cs │ ├── Geometry │ │ ├── IPoint.cs │ │ ├── IPoint3.cs │ │ ├── IRectangle.cs │ │ └── IRectangle3.cs │ ├── ILocation.cs │ ├── ILogMessage.cs │ ├── IMessageSink.cs │ ├── Loyc.Interfaces.csproj │ ├── Loyc.Interfaces.net45.csproj │ ├── Math │ │ └── Interfaces.cs │ ├── Misc.cs │ ├── MiscInterfaces.cs │ ├── NamespaceDocs.cs │ ├── OpenSourceKey.snk │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Syntax │ │ ├── IIndexPositionMapper.cs │ │ ├── ILNode.cs │ │ ├── ILNodePrinterOptions.cs │ │ ├── ILineColumnFile.cs │ │ ├── ILiteralParser.cs │ │ ├── ILiteralPrinter.cs │ │ ├── ILiteralValue.cs │ │ ├── ISourceFile.cs │ │ ├── ISourceRange.cs │ │ ├── NodeStyle.cs │ │ └── ParsingMode.cs ├── Loyc.Math.nuspec ├── Loyc.Math │ ├── Geometry │ │ ├── BoundingBox.cs │ │ ├── BoundingBoxMathTT.cs │ │ ├── BoundingBoxMathTT.tt │ │ ├── LineMath.cs │ │ ├── LineMathTT.cs │ │ ├── LineMathTT.tt │ │ ├── LineSegment.cs │ │ ├── PointExt.cs │ │ ├── PointMath.cs │ │ ├── PointMathTT.cs │ │ ├── PointMathTT.tt │ │ ├── PointT.cs │ │ ├── PolygonMathTT.cs │ │ ├── PolygonMathTT.tt │ │ ├── Rectangle3Ext.cs │ │ ├── RectangleExt.cs │ │ ├── Vector3T.cs │ │ └── VectorT.cs │ ├── Loyc.Math.csproj │ ├── Loyc.Math.net45.csproj │ ├── Math │ │ ├── FixedPoint.cs │ │ ├── FixedPoint.tt │ │ ├── Math128.cs │ │ ├── MathEx.cs │ │ ├── Maths.cs │ │ ├── Maths.tt │ │ ├── MathsT.cs │ │ └── NumTraits.ttinclude │ ├── OpenSourceKey.snk │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Range.ecs │ └── Range.out.cs ├── Loyc.Syntax.nuspec ├── Loyc.Syntax │ ├── CodeSymbols.cs │ ├── ILNodePrinterHelper.cs │ ├── IParsingOptions.cs │ ├── IParsingService.cs │ ├── LES │ │ ├── CustomLiteral.cs │ │ ├── INodePrinterWriter.cs │ │ ├── Les2LanguageService.cs │ │ ├── Les2Lexer.cs │ │ ├── Les2LexerGrammar.les │ │ ├── Les2LexerGrammar.out.cs │ │ ├── Les2Parser.cs │ │ ├── Les2ParserGrammar.les │ │ ├── Les2ParserGrammar.out.cs │ │ ├── Les2Printer.cs │ │ ├── Les2PrinterWriter.cs │ │ ├── Les3.cs │ │ ├── Les3LanguageService.cs │ │ ├── Les3Lexer.ecs │ │ ├── Les3Lexer.out.cs │ │ ├── Les3Parser.ecs │ │ ├── Les3Parser.out.cs │ │ ├── Les3PrettyPrinter.cs │ │ ├── Les3Printer.cs │ │ ├── Les3PrinterOptions.cs │ │ ├── Les3Printer_CanPrintAsNumber.ecs │ │ ├── Les3Printer_CanPrintAsNumber.out.cs │ │ ├── LesPrecedence.cs │ │ ├── LesPrecedenceMap.cs │ │ └── TokenType.cs │ ├── LNodePrinterHelper.cs │ ├── LNodes │ │ ├── AbstractNodes.cs │ │ ├── DescendantsFrame.cs │ │ ├── ILNodePrinter.cs │ │ ├── ILiteralValueProvider.cs │ │ ├── LNode.cs │ │ ├── LNodeExt.cs │ │ ├── LNodeFactory.cs │ │ ├── LNodeList.cs │ │ ├── LNodePrintingOptions.cs │ │ ├── LNodeVisitor.cs │ │ ├── LiteralFromParser.cs │ │ ├── LiteralValue.cs │ │ ├── StdCallNode.cs │ │ ├── StdIdNode.cs │ │ ├── StdLiteralNode.cs │ │ ├── StdTriviaNode.cs │ │ └── UninterpretedLiteral.cs │ ├── LeMP │ │ ├── IMacroContext.cs │ │ └── MacroAttributes.cs │ ├── Lexing │ │ ├── BaseILexer.cs │ │ ├── BaseLexer.cs │ │ ├── CharCategories.html │ │ ├── CharCategory.ecs │ │ ├── CharCategory.out.cs │ │ ├── ILexer.cs │ │ ├── ILllpgApi.cs │ │ ├── IndentTokenGenerator.cs │ │ ├── LexerSource.cs │ │ ├── Token.cs │ │ ├── TokenKind.cs │ │ ├── TokenListAsLexer.cs │ │ ├── TokenTree.cs │ │ ├── TokensToTree.cs │ │ ├── TriviaSaver.cs │ │ ├── UnicodeData.txt │ │ └── WhitespaceFilter.cs │ ├── Loyc.Syntax.csproj │ ├── Loyc.Syntax.net45.csproj │ ├── NodeLocationMapper.cs │ ├── OpenSourceKey.snk │ ├── Parsing │ │ ├── AbstractTriviaInjector.cs │ │ ├── BaseParser.cs │ │ ├── BaseParserForList.cs │ │ ├── BaseParserNoBacktracking.cs │ │ ├── LiteralHandlerTable.cs │ │ ├── OperatorShape.cs │ │ ├── ParseHelpers.cs │ │ ├── ParserSource.cs │ │ ├── Precedence.cs │ │ ├── StandardLiteralHandlers.cs │ │ └── StandardTriviaInjector.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── SourceFiles │ │ ├── IndexPositionMapper.cs │ │ ├── LineRemapper.cs │ │ ├── SourceFile.cs │ │ ├── SourceRange.cs │ │ └── StreamCharSource.cs ├── Loyc.Utilities.nuspec ├── Loyc.Utilities │ ├── Collections │ │ ├── AListExt.cs │ │ ├── AListStatisticTracker.cs │ │ ├── CPTrie │ │ │ ├── Benchmark.xlsx │ │ │ ├── CPBNode.cs │ │ │ ├── CPBitArrayLeaf.cs │ │ │ ├── CPByteTrie.cs │ │ │ ├── CPIntTrie.cs │ │ │ ├── CPSNode.cs │ │ │ ├── CPStringTrie.cs │ │ │ ├── CPTrie.cs │ │ │ ├── CPTrieBenchmark.cs │ │ │ ├── CPTrieMisc.cs │ │ │ ├── CPTrieTests.cs │ │ │ └── remember.txt │ │ └── KeylessHashtable.cs │ ├── GoInterface test project │ │ ├── GoInterface tests.csproj │ │ ├── GoInterface tests.sln │ │ ├── Program.cs │ │ ├── app.config │ │ └── nunit.framework.dll │ ├── GoInterface.cs │ ├── GoInterfaceBenchmark.cs │ ├── IntSet.cs │ ├── Loyc.Utilities.csproj │ ├── Loyc.Utilities.net45.csproj │ ├── OpenSourceKey.snk │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SimpleTimer.cs │ ├── Statistic.cs │ ├── SymbolSet.cs │ ├── TagsInWList.cs │ ├── UG.cs │ └── app.config ├── LoycCore.Benchmarks │ ├── Benchmarks │ │ ├── Benchmark.cs │ │ ├── BenchmarkSets.cs │ │ ├── Benchmarker.cs │ │ ├── EzChartForm.Designer.cs │ │ ├── EzChartForm.cs │ │ ├── EzChartForm.resx │ │ ├── GoInterfaceBenchmark.cs │ │ └── ListBenchmarks.cs │ ├── LoycCore.Benchmarks.net45.csproj │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Resources │ │ ├── 2of12.txt │ │ ├── Resources.Designer.cs │ │ └── Resources.resx │ └── packages.config ├── LoycCore.netfx.sln ├── LoycCore.netstd.sln ├── LoycCore.nuspec ├── MiniTestRunner │ ├── MiniTestRunner.net45.csproj │ ├── Model │ │ ├── ApplicationModel.cs │ │ ├── ContainerRowModel.cs │ │ ├── CrossDomainPropertyChangeHandler.cs │ │ ├── IRowModel.cs │ │ ├── NPCHelper.cs │ │ ├── OptionsModel.cs │ │ ├── ProjectModel.cs │ │ ├── ResultSet.cs │ │ ├── RowModel.cs │ │ ├── TaskRowModel.cs │ │ ├── TaskRunner.cs │ │ └── TreeModel.cs │ ├── OpenSourceKey.snk │ ├── Program.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ ├── Resources │ │ ├── Assembly.png │ │ ├── Benchmark.png │ │ ├── Class.png │ │ ├── HighPriority.png │ │ ├── LowPriority.png │ │ ├── OpenProject.png │ │ ├── ResultSet.png │ │ ├── RunIcon.png │ │ ├── SplitHorizontal.png │ │ ├── StatusError.png │ │ ├── StatusFlag.png │ │ ├── StatusIgnored.png │ │ ├── StatusMessage.png │ │ ├── StatusNote.png │ │ ├── StatusRunning.png │ │ ├── StatusSuccess.png │ │ ├── StatusUnknown.png │ │ ├── StatusWarning.png │ │ ├── StopIcon.png │ │ ├── Test.png │ │ ├── TestSet.png │ │ ├── TreeOnly.png │ │ └── WordWrap.png │ ├── TestDomain │ │ ├── AssemblyScanTask.cs │ │ ├── IPropertyChanged.cs │ │ ├── ITask.cs │ │ ├── TaskBase.cs │ │ └── UnitTestTask.cs │ ├── Utils │ │ ├── AppDomainStarter.cs │ │ ├── BaseDictionary.cs │ │ ├── RecycleBin.cs │ │ ├── ViewModelOf.cs │ │ ├── WeakKeyComparer.cs │ │ ├── WeakKeyDictionary.cs │ │ └── WeakReference.cs │ ├── View │ │ ├── RowView.cs │ │ ├── TestingForm.Designer.cs │ │ ├── TestingForm.cs │ │ ├── TestingForm.resx │ │ └── TreeViewAdvModel.cs │ ├── ViewModel │ │ ├── DisplaySettingsVM.cs │ │ ├── FilterVM.cs │ │ ├── RowVM.cs │ │ └── TreeVM.cs │ └── app.config ├── Readme.md └── Tests │ ├── Collections │ ├── ALists │ │ ├── AListBaseTests.cs │ │ ├── AListTestHelpersBase.cs │ │ ├── AListTests.cs │ │ ├── BDictionaryTests.cs │ │ ├── BListTests.cs │ │ ├── BMultiMapTests.cs │ │ └── SparseAListTests.cs │ ├── DequeTests.cs │ ├── DictionaryTests.cs │ ├── HeapTests.cs │ ├── InternalDArrayTests.cs │ ├── ListCollectionTests.cs │ ├── ListRangeTests.cs │ ├── ListTests.cs │ ├── MapTests.cs │ ├── ReadOnlyDictionaryTests.cs │ ├── SetTests.cs │ ├── TypeDictionaryWithBaseTypeLookupsTests.cs │ └── VLists │ │ ├── FVListTests.cs │ │ ├── FWListTests.cs │ │ ├── VListTests.cs │ │ └── WListTests.cs │ ├── Essentials │ ├── BaisTests.cs │ ├── CollectionWithChangeEventsTests.cs │ ├── DictionaryWithChangeEventsTests.cs │ ├── DictionaryWrapperTests.cs │ ├── Either.cs │ ├── ExtensionsTests.cs │ ├── GTests.cs │ ├── HashTagsTests.cs │ ├── ListExtTests.cs │ ├── ListWithChangeEventsTests.cs │ ├── ListWrapperTests.cs │ ├── LocalizeTests.cs │ ├── PrintHelpersTests.cs │ ├── SliceTests.cs │ ├── SymbolTests.cs │ ├── ThreadExTests.cs │ └── UStringTests.cs │ ├── LoycCore.Tests.csproj │ ├── LoycCore.Tests.net45.csproj │ ├── Math │ ├── LineMathTests.cs │ ├── MathExTests.cs │ └── PointMathTests.cs │ ├── OpenSourceKey.snk │ ├── Program.cs │ ├── Syntax │ ├── IndentTokenGeneratorTests.cs │ ├── IndexPositionMapperTests.cs │ ├── LNodePrinterHelperTests.cs │ ├── LNodeRangeMapperTests.cs │ ├── LNodeTests.cs │ ├── Les2LexerTests.cs │ ├── Les2ParserTests.cs │ ├── Les2PrinterAndParserTests.cs │ ├── Les2PrinterTests.cs │ ├── Les3LexerTests.cs │ ├── Les3ParserTests.cs │ ├── Les3PrinterAndParserTests.cs │ ├── Les3PrinterTests.cs │ ├── LexerSourceTest.ecs │ ├── LexerSourceTest.out.cs │ ├── LiteralHandlerTableTests.cs │ ├── MiscTests.cs │ ├── ParseHelperTests.cs │ ├── ParserSourceTest.ecs │ ├── ParserSourceTest.out.cs │ ├── StandardLiteralHandlersTests.cs │ ├── StandardTriviaInjectorTests.cs │ ├── StreamCharSourceTests.cs │ ├── TokenTests.cs │ └── TokensToTreeTests.cs │ ├── TestHelpers.cs │ └── Utilities │ ├── AListSummaryTrackerTests.cs │ ├── GoInterfaceTests.cs │ ├── IntSetTests.cs │ ├── TagsInWListTests.cs │ └── UGTests.cs ├── Doc ├── OldDocs │ ├── EC# for normal people.txt │ ├── EC#.cs │ ├── EC#2.cs │ └── Set benchmark results.csv ├── Please see docs on ecsharp.net └── VeryOldDocs │ ├── 50features.html │ ├── Help File Project.shfb │ ├── design-ov.html │ ├── extensions-ov.html │ ├── loyc-intro.html │ ├── notes.txt │ ├── onep.html │ ├── readme.txt │ ├── symbol-resolution.html │ ├── syntax-ov.html │ ├── syntax-ov2.html │ └── thanks.html ├── Lib ├── ICSharpCode.TextEditor.dll ├── protobuf-net.dll ├── protobuf-net.pdb └── protobuf-net.xml ├── License.txt ├── Loyc.all.sln ├── Loyc.netfx.sln ├── Loyc.netstd.sln ├── Main ├── Ecs │ ├── EcsCodeSymbols.cs │ ├── EcsFacts.cs │ ├── EcsPrecedence.cs │ ├── EcsValidators.cs │ ├── Loyc.Ecs.csproj │ ├── Loyc.Ecs.net4x.csproj │ ├── OpenSourceKey.snk │ ├── Parser │ │ ├── EcsLanguageService.cs │ │ ├── EcsLexer.cs │ │ ├── EcsLexerGrammar.les │ │ ├── EcsLexerGrammar.out.cs │ │ ├── EcsLiteralHandlers.cs │ │ ├── EcsParser.cs │ │ ├── EcsParserGrammar.les │ │ ├── EcsParserGrammar.out.cs │ │ ├── EcsPreprocessor.cs │ │ ├── EcsTriviaInjector.cs │ │ └── TokenType.cs │ ├── Printer │ │ ├── EcsNodePrinter--expressions.cs │ │ ├── EcsNodePrinter--statements.cs │ │ ├── EcsNodePrinter.cs │ │ └── EcsNodePrinterWriter.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Tests │ │ ├── AmbiguityTests.cs │ │ ├── BugsAndCornerCases.cs │ │ ├── ECSharpFeatureTests.cs │ │ ├── EcsLexerTests.cs │ │ ├── EcsParserTests.cs │ │ ├── EcsPrinterAndParserTests.cs │ │ ├── EcsPrinterTests.cs │ │ ├── EcsValidatorTests.cs │ │ ├── LinqTests.cs │ │ ├── PlainCSharpTests.cs │ │ ├── PrinterFocusedTests.cs │ │ ├── ToDoTests.cs │ │ └── TriviaTests.cs ├── ICSharpCode.TextEditor │ ├── .gitignore │ ├── ICSharpCode.TextEditor.sln │ ├── Project │ │ ├── Article1.cd │ │ ├── Article2.cd │ │ ├── Configuration │ │ │ ├── AssemblyInfo.cs │ │ │ └── GlobalAssemblyInfo.cs │ │ ├── ICSharpCode.TextEditor.cd │ │ ├── ICSharpCode.TextEditor.csproj │ │ ├── ICSharpCode.TextEditor.dll.nuspec │ │ ├── ICSharpCode.TextEditor.sln │ │ ├── Resources │ │ │ ├── ASPX.xshd │ │ │ ├── BAT-Mode.xshd │ │ │ ├── Boo.xshd │ │ │ ├── CPP-Mode.xshd │ │ │ ├── CSharp-Mode.xshd │ │ │ ├── Coco-Mode.xshd │ │ │ ├── HTML-Mode.xshd │ │ │ ├── ICSharpCode.TextEditor.snk │ │ │ ├── Java-Mode.xshd │ │ │ ├── JavaScript-Mode.xshd │ │ │ ├── Mode.xsd │ │ │ ├── PHP-Mode.xshd │ │ │ ├── Patch-Mode.xshd │ │ │ ├── Python-Mode.xshd │ │ │ ├── RightArrow.cur │ │ │ ├── SyntaxModes.xml │ │ │ ├── Tex-Mode.xshd │ │ │ ├── TextEditorControl.bmp │ │ │ ├── VBNET-Mode.xshd │ │ │ └── XML-Mode.xshd │ │ └── Src │ │ │ ├── Actions │ │ │ ├── BookmarkActions.cs │ │ │ ├── CaretActions.cs │ │ │ ├── ClipBoardActions.cs │ │ │ ├── FoldActions.cs │ │ │ ├── FormatActions.cs │ │ │ ├── HomeEndActions.cs │ │ │ ├── IEditAction.cs │ │ │ ├── MiscActions.cs │ │ │ └── SelectionActions.cs │ │ │ ├── Document │ │ │ ├── AbstractSegment.cs │ │ │ ├── BookmarkManager │ │ │ │ ├── Bookmark.cs │ │ │ │ ├── BookmarkEventHandler.cs │ │ │ │ ├── BookmarkManager.cs │ │ │ │ └── BookmarkManagerMemento.cs │ │ │ ├── DefaultDocument.cs │ │ │ ├── DefaultTextEditorProperties.cs │ │ │ ├── DocumentEventArgs.cs │ │ │ ├── DocumentFactory.cs │ │ │ ├── FoldingStrategy │ │ │ │ ├── FoldMarker.cs │ │ │ │ ├── FoldingManager.cs │ │ │ │ ├── IFoldingStrategy.cs │ │ │ │ └── IndentFoldingStrategy.cs │ │ │ ├── FormattingStrategy │ │ │ │ ├── DefaultFormattingStrategy.cs │ │ │ │ └── IFormattingStrategy.cs │ │ │ ├── HighlightingStrategy │ │ │ │ ├── DefaultHighlightingStrategy.cs │ │ │ │ ├── FontContainer.cs │ │ │ │ ├── HighlightBackground.cs │ │ │ │ ├── HighlightColor.cs │ │ │ │ ├── HighlightInfo.cs │ │ │ │ ├── HighlightRuleSet.cs │ │ │ │ ├── HighlightingColorNotFoundException.cs │ │ │ │ ├── HighlightingDefinitionInvalidException.cs │ │ │ │ ├── HighlightingDefinitionParser.cs │ │ │ │ ├── HighlightingManager.cs │ │ │ │ ├── HighlightingStrategyFactory.cs │ │ │ │ ├── IHighlightingStrategy.cs │ │ │ │ ├── NextMarker.cs │ │ │ │ ├── PrevMarker.cs │ │ │ │ ├── Span.cs │ │ │ │ ├── SpanStack.cs │ │ │ │ ├── SyntaxModes │ │ │ │ │ ├── FileSyntaxModeProvider.cs │ │ │ │ │ ├── ISyntaxModeFileProvider.cs │ │ │ │ │ ├── ResourceSyntaxModeProvider.cs │ │ │ │ │ └── SyntaxMode.cs │ │ │ │ └── TextWord.cs │ │ │ ├── IDocument.cs │ │ │ ├── ISegment.cs │ │ │ ├── ITextEditorProperties.cs │ │ │ ├── LineManager │ │ │ │ ├── DeferredEventList.cs │ │ │ │ ├── LineManager.cs │ │ │ │ ├── LineManagerEventArgs.cs │ │ │ │ ├── LineSegment.cs │ │ │ │ └── LineSegmentTree.cs │ │ │ ├── MarkerStrategy │ │ │ │ ├── MarkerStrategy.cs │ │ │ │ └── TextMarker.cs │ │ │ ├── Selection │ │ │ │ ├── ColumnRange.cs │ │ │ │ ├── DefaultSelection.cs │ │ │ │ ├── ISelection.cs │ │ │ │ └── SelectionManager.cs │ │ │ ├── TextAnchor.cs │ │ │ ├── TextBufferStrategy │ │ │ │ ├── GapTextBufferStrategy.cs │ │ │ │ ├── ITextBufferStrategy.cs │ │ │ │ └── StringTextBufferStrategy.cs │ │ │ ├── TextLocation.cs │ │ │ └── TextUtilities.cs │ │ │ ├── Gui │ │ │ ├── AbstractMargin.cs │ │ │ ├── BracketHighlighter.cs │ │ │ ├── BrushRegistry.cs │ │ │ ├── Caret.cs │ │ │ ├── CompletionWindow │ │ │ │ ├── AbstractCompletionWindow.cs │ │ │ │ ├── CodeCompletionListView.cs │ │ │ │ ├── CodeCompletionWindow.cs │ │ │ │ ├── DeclarationViewWindow.cs │ │ │ │ ├── ICompletionData.cs │ │ │ │ └── ICompletionDataProvider.cs │ │ │ ├── DrawableLine.cs │ │ │ ├── FoldMargin.cs │ │ │ ├── GutterMargin.cs │ │ │ ├── HRuler.cs │ │ │ ├── IconBarMargin.cs │ │ │ ├── Ime.cs │ │ │ ├── InsightWindow │ │ │ │ ├── IInsightDataProvider.cs │ │ │ │ └── InsightWindow.cs │ │ │ ├── TextArea.cs │ │ │ ├── TextAreaClipboardHandler.cs │ │ │ ├── TextAreaControl.cs │ │ │ ├── TextAreaDragDropHandler.cs │ │ │ ├── TextAreaMouseHandler.cs │ │ │ ├── TextAreaUpdate.cs │ │ │ ├── TextEditorControl.cs │ │ │ ├── TextEditorControlBase.cs │ │ │ ├── TextView.cs │ │ │ └── ToolTipRequestEventArgs.cs │ │ │ ├── Undo │ │ │ ├── IUndoableOperation.cs │ │ │ ├── UndoQueue.cs │ │ │ ├── UndoStack.cs │ │ │ ├── UndoableDelete.cs │ │ │ ├── UndoableInsert.cs │ │ │ └── UndoableReplace.cs │ │ │ └── Util │ │ │ ├── AugmentableRedBlackTree.cs │ │ │ ├── CheckedList.cs │ │ │ ├── FileReader.cs │ │ │ ├── LoggingService.cs │ │ │ ├── LookupTable.cs │ │ │ ├── MouseWheelHandler.cs │ │ │ ├── RedBlackTreeIterator.cs │ │ │ ├── RtfWriter.cs │ │ │ ├── TextUtility.cs │ │ │ ├── TipPainter.cs │ │ │ ├── TipPainterTools.cs │ │ │ ├── TipSection.cs │ │ │ ├── TipSpacer.cs │ │ │ ├── TipSplitter.cs │ │ │ ├── TipText.cs │ │ │ └── WeakCollection.cs │ └── Test │ │ ├── AssemblyInfo.cs │ │ ├── BlockCommentTests.cs │ │ ├── DocumentTests.cs │ │ ├── FoldingManagerTests.cs │ │ ├── ICSharpCode.TextEditor.Tests.csproj │ │ ├── TextMarkerTests.cs │ │ └── packages.config ├── LLLPG.nuspec ├── LLLPG │ ├── App.config │ ├── CodeGenHelpers │ │ ├── CodeGenHelperBase.cs │ │ ├── GeneralCodeGenHelper.cs │ │ ├── IPGCodeGenHelper.cs │ │ ├── IntStreamCodeGenHelper.cs │ │ └── PGIntSet.cs │ ├── CoreEngine │ │ ├── AnalysisVisitors.cs │ │ ├── GenerateCodeVisitor.cs │ │ ├── IPGTerminalSet.cs │ │ ├── KthSet.cs │ │ ├── LLParserGenerator.cs │ │ └── PredictionTree.cs │ ├── LLLPG.csproj │ ├── LLLPG.net4x.csproj │ ├── LLLPG.png │ ├── OpenSourceKey.snk │ ├── ParsersAndMacros │ │ ├── AntlrStyleParserGrammar.ecs │ │ ├── AntlrStyleParserGrammar.out.cs │ │ ├── AutoValueSaverVisitor.cs │ │ ├── Macros.cs │ │ ├── StageOneParser.cs │ │ ├── StageOneParserGrammar.ecs │ │ ├── StageOneParserGrammar.out.cs │ │ └── StageTwoParser.cs │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── RuleAndPreds │ │ ├── PredVisitor.cs │ │ ├── Predicates.cs │ │ └── Rule.cs │ └── Tests │ │ ├── LlpgAutoValueSaverVisitorTests.cs │ │ ├── LlpgBugsAndSlugs.cs │ │ ├── LlpgCoreTests.cs │ │ ├── LlpgGeneralTests.cs │ │ ├── LlpgGeneralTestsBase.cs │ │ ├── LlpgParserTests.cs │ │ └── LlpgTestLargerExamples.cs ├── LeMP-Tool.nuspec ├── LeMP.StdMacros │ ├── CSharpForwardPipeArrow.cs │ ├── CSharpX.To.OlderVersions │ │ ├── CSharp6Macros.cs │ │ └── CSharp7Macros.cs │ ├── DefineMacro.cs │ ├── LeMP.StdMacros.csproj │ ├── LeMP.StdMacros.net4x.csproj │ ├── OpenSourceKey.snk │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── ReplaceMacro.cs │ ├── StandardMacros.cs │ ├── StaticMatchCodeMacro.cs │ ├── UnrollMacro.cs │ ├── ecs │ │ ├── AddLineDirectivesMacro.cs │ │ ├── AlgebraicDataType.ecs │ │ ├── AlgebraicDataType.out.cs │ │ ├── AssertMacro.ecs │ │ ├── AssertMacro.out.cs │ │ ├── BackingFieldMacro.cs │ │ ├── CodeQuoteMacro.cs │ │ ├── CompileTimeMacro.cs │ │ ├── ContractsMacro.ecs │ │ ├── ContractsMacro.out.cs │ │ ├── DeconstructMacro.cs │ │ ├── ForwardingMacro.cs │ │ ├── InRange.ecs │ │ ├── InRange.out.cs │ │ ├── Literals.ecs │ │ ├── Literals.out.cs │ │ ├── MatchCode.ecs │ │ ├── MatchCode.out.cs │ │ ├── OnFinallyThrowCatch.cs │ │ ├── OnReturn.ecs │ │ ├── OnReturn.out.cs │ │ ├── SaveAndRestoreMacro.ecs │ │ ├── SaveAndRestoreMacro.out.cs │ │ ├── SetOrCreateMemberMacro.cs │ │ ├── StandardMacros.cs │ │ ├── ThisConstructorMacro.cs │ │ ├── UseSequenceExpressions.ecs │ │ ├── UseSequenceExpressions.out.cs │ │ ├── UseSymbolsMacro.cs │ │ ├── UserDefinedMacroMacro.ecs │ │ ├── UserDefinedMacroMacro.out.cs │ │ ├── UsingMultiMacro.ecs │ │ ├── UsingMultiMacro.out.cs │ │ ├── WithMacro.cs │ │ └── deprecated │ │ │ ├── InRange.ecs │ │ │ ├── InRange.out.cs │ │ │ ├── MatchMacro.ecs │ │ │ └── MatchMacro.out.cs │ ├── lesX.to.ecs │ │ ├── les2.to.ecs.Macros.cs │ │ ├── les3.to.ecs.Macros.cs │ │ └── les3.to.ecs.Macros.ecs │ └── packages.config ├── LeMP.nuspec ├── LeMP │ ├── App.config │ ├── BuiltinMacros.cs │ ├── Compiler.cs │ ├── DotnetToolSettings.xml │ ├── EC#.ico │ ├── EC#.pdn │ ├── LeMP.csproj │ ├── LeMP.net4x.csproj │ ├── MacroProcessor.cs │ ├── MacroProcessorTask.cs │ ├── OpenSourceKey.snk │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Tests │ │ ├── CompilerTests.cs │ │ ├── LiteralTests.cs │ │ ├── MacroProcessorTests.cs │ │ ├── MacroTesterBase.cs │ │ ├── PreludeMacroTests_Les2.cs │ │ ├── PreludeMacroTests_Les3.cs │ │ ├── SmallerMacroTests.cs │ │ ├── TestAlgebraicDataTypes.cs │ │ ├── TestCodeContractMacros.cs │ │ ├── TestCodeQuoteMacro.cs │ │ ├── TestCompileTimeMacros.cs │ │ ├── TestMacroCombinations.cs │ │ ├── TestMatchCodeMacro.cs │ │ ├── TestMatchMacro.cs │ │ ├── TestOnFinallyReturnThrowMacros.cs │ │ ├── TestReplaceAndDefineMacros.cs │ │ ├── TestSequenceExpressionMacro.cs │ │ ├── TestSetOrCreateMemberMacro.cs │ │ ├── TestStaticDeconstructMacro.cs │ │ ├── TestStaticMatchCodeMacro.cs │ │ ├── TestUnrollMacro.cs │ │ ├── TestUseSymbolsMacro.cs │ │ └── TestUserDefinedMacroMacro.cs ├── LeMPDemo │ ├── App.config │ ├── EC#.ico │ ├── FindAndReplaceForm.Designer.cs │ ├── FindAndReplaceForm.cs │ ├── FindAndReplaceForm.resx │ ├── InputBox.cs │ ├── LeMPDemo.net4x.csproj │ ├── LempDemoForm.Designer.cs │ ├── LempDemoForm.cs │ ├── LempDemoForm.resx │ ├── LempDemoPanel.Designer.cs │ ├── LempDemoPanel.cs │ ├── LempDemoPanel.resx │ └── Program.cs ├── Loyc.Ecs.nuspec └── Tests │ ├── App.config │ ├── PlayPen.ecs │ ├── PlayPen.out.cs │ ├── Program.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── Samples.ecs │ ├── Samples.out.cs │ ├── Samples2.cs │ ├── Tests.csproj │ └── Tests.net4x.csproj ├── Readme.md ├── UpdateLibLeMPAndReinstall.bat ├── Visual Studio Integration ├── Example.les ├── Example.samplelang ├── LoycForVS2022 │ ├── LeMP_VisualStudio.csproj │ ├── License.txt │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SFG │ │ ├── CustomToolBase.cs │ │ └── LoycCustomTools.cs │ ├── SyntaxHighlights │ │ ├── BackgroundAnalyzerForVS.cs │ │ ├── BraceMatchingTagger.cs │ │ ├── EcsSyntaxForVS.cs │ │ ├── Les2SyntaxForVs.cs │ │ ├── Les3SyntaxForVS.cs │ │ ├── SampleLanguage.cs │ │ ├── SyntaxAnalyzerForVS.cs │ │ ├── SyntaxClassifierForVS.cs │ │ ├── TextSnapshotAsSourceFile.cs │ │ └── VSBuffer.cs │ ├── app.config │ ├── packages.config │ └── source.extension.vsixmanifest ├── Visual Studio Integration 2022.sln ├── notepad++userDefinedLang_les.xml └── notepad++userDefinedLang_les_dark.xml └── appveyor.yml /.editorconfig: -------------------------------------------------------------------------------- 1 | [*.{cs,ecs,tt}] 2 | end_of_line = lf 3 | indent_style = tab 4 | charset = utf-8 5 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Normalize line endings of *.cs (text=auto is supposed to mean "use LFs") 2 | *.cs text=auto eol=lf 3 | # Normalize line endings of *.ecs (eol=lf is supposed to mean "store LFs in working directory") 4 | *.ecs text=auto eol=lf 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: csharp 2 | solution: Loyc.netstd.sln 3 | install: 4 | # Restore NuGet packages first 5 | - nuget restore Loyc.netstd.sln 6 | script: 7 | # Build the Loyc libraries in release mode, for all possible configurations. 8 | - xbuild /p:Configuration=Release Loyc.netstd.sln 9 | 10 | # Unfortunately, test set 8 (LLLPG) sometimes fails due to nondeterminism. 11 | - mono Bin/Release/netstandard2.0/Tests.exe 1 12 | - mono Bin/Release/netstandard2.0/Tests.exe 2 13 | - mono Bin/Release/netstandard2.0/Tests.exe 3 14 | - mono Bin/Release/netstandard2.0/Tests.exe 4 15 | - mono Bin/Release/netstandard2.0/Tests.exe 5 16 | - mono Bin/Release/netstandard2.0/Tests.exe 6 17 | - mono Bin/Release/netstandard2.0/Tests.exe 7 18 | -------------------------------------------------------------------------------- /Core/AssemblyVersion.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | [assembly: AssemblyCopyright("Copyright ©2019. Licence: LGPL")] 4 | 5 | // Version information for an assembly consists of the following four values: 6 | // 7 | // Major Version 8 | // Minor Version 9 | // Build Number 10 | // Revision 11 | // 12 | // You can specify all the values or you can default the Build and Revision Numbers 13 | // by using '.*' - but you shouldn't, because it will cause a simple "Rebuild All" 14 | // command to change the version number which, I guess, produces an incompatible 15 | // assembly in the presence of strong names (strong naming prevents two assemblies 16 | // from linking together without an exact match.) 17 | [assembly: AssemblyVersion("30.1.3")] 18 | [assembly: AssemblyFileVersion("30.1.3")] 19 | -------------------------------------------------------------------------------- /Core/Lib/Aga.Controls.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/Lib/Aga.Controls.dll -------------------------------------------------------------------------------- /Core/Lib/UpdateControls.Forms.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/Lib/UpdateControls.Forms.dll -------------------------------------------------------------------------------- /Core/Lib/UpdateControls.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/Lib/UpdateControls.dll -------------------------------------------------------------------------------- /Core/Loyc.Collections.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Loyc.Collections 5 | $version$ 6 | David Piepgrass 7 | David Piepgrass 8 | http://core.loyc.net 9 | 10 | Readme.md 11 | false 12 | Defines a number of sophisticated data structures. 13 | Loyc.Collections is a library of sophisticated data structures that implement standard .NET collection interfaces. It includes ALists, VLists, hash tree types (Set<T>, MSet<T>, Map<K,V> and MMap<K,V>), and min/max heaps. 14 | See http://core.loyc.net/version-history 15 | Copyright 2020 16 | Loyc Core Collections Extension-Methods Dictionary Trees AList BList DList VList Cache Sparse-List Hash-Trees 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Core/Loyc.Collections/Loyc.Collections.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netstandard2.0 4 | ..\Bin\$(Configuration)\ 5 | 1591, 1573, 0419 6 | true 7 | OpenSourceKey.snk 8 | false 9 | 10 | 11 | true 12 | ..\Bin\$(Configuration)\$(TargetFramework)\Loyc.Collections.xml 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Core/Loyc.Collections/OpenSourceKey.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/Loyc.Collections/OpenSourceKey.snk -------------------------------------------------------------------------------- /Core/Loyc.Collections/Other/ArrayOf4.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Diagnostics; 6 | 7 | namespace Loyc.Collections 8 | { 9 | class ArrayOf4 10 | { 11 | T t0, t1, t2, t3; 12 | 13 | T A { get { return t0; } set { t0 = value; } } 14 | T B { get { return t1; } set { t1 = value; } } 15 | T C { get { return t2; } set { t2 = value; } } 16 | T D { get { return t3; } set { t3 = value; } } 17 | 18 | public T this[int index] 19 | { 20 | get { 21 | Debug.Assert((uint)index < (uint)4); 22 | if (index < 2) 23 | return index > 0 ? t1 : t0; 24 | else 25 | return index == 2 ? t2 : t3; 26 | } 27 | set { 28 | Debug.Assert((uint)index < (uint)4); 29 | if (index < 2) { 30 | if (index == 0) 31 | t0 = value; 32 | else 33 | t1 = value; 34 | } else { 35 | if (index == 2) 36 | t2 = value; 37 | else 38 | t3 = value; 39 | } 40 | } 41 | } 42 | public T Insert(int index, T item) 43 | { 44 | T popped = t3; 45 | t3 = t2; 46 | if (index < 2) { 47 | t2 = t1; 48 | if (index == 0) 49 | t0 = item; 50 | else 51 | t1 = item; 52 | return popped; 53 | } else { 54 | if (index == 2) 55 | t2 = item; 56 | else 57 | t3 = item; 58 | return popped; 59 | } 60 | } 61 | public void RemoveAt(int index, T newFourth) 62 | { 63 | if (index < 2) 64 | { 65 | if (index == 0) 66 | t0 = t1; 67 | t1 = t2; 68 | } 69 | if (index == 2) 70 | t2 = t3; 71 | t3 = newFourth; 72 | } 73 | public T First 74 | { 75 | get { return t0; } 76 | set { t0 = value; } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Core/Loyc.Collections/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Loyc.Collections")] 9 | [assembly: AssemblyDescription("A library of data structures including ALists, VLists, and my favorite, the hash tree types Set, MSet, Map and MMap. "+ 10 | "To learn more visit http://core.loyc.net/collections")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("David Piepgrass")] 13 | [assembly: AssemblyProduct("Loyc.Collections")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("d8c0cb64-7255-4d54-b246-cf2653d4164a")] 24 | 25 | //[assembly: InternalsVisibleTo("LoycCore.Tests")] is not allowed in a signed assembly 26 | [assembly: InternalsVisibleTo("LoycCore.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100adec5c8e52098b94dc60b34ac0916d307eec23b2c285a0beeb7168174fc1f6a71dcae43c88904e2907a12f66861de8d8f130c4f7b57cff0aea92ed06b50d96c63cea2ee19ec5d35a2946ddef3f35f0fbd3ec3a358b46fd05c82837c49d91694c1926935dc83e2a28c1ff077e4d8a5f679f1edb1c8a692aa2913d753ea05f4fba")] 27 | 28 | -------------------------------------------------------------------------------- /Core/Loyc.Collections/VLists/Diagrams/ChangingPList.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/Loyc.Collections/VLists/Diagrams/ChangingPList.png -------------------------------------------------------------------------------- /Core/Loyc.Collections/VLists/Diagrams/IdealVList.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/Loyc.Collections/VLists/Diagrams/IdealVList.png -------------------------------------------------------------------------------- /Core/Loyc.Collections/VLists/Diagrams/LinkedList.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/Loyc.Collections/VLists/Diagrams/LinkedList.png -------------------------------------------------------------------------------- /Core/Loyc.Collections/VLists/Diagrams/PathologicalVList.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/Loyc.Collections/VLists/Diagrams/PathologicalVList.png -------------------------------------------------------------------------------- /Core/Loyc.Collections/VLists/Diagrams/VListSharing1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/Loyc.Collections/VLists/Diagrams/VListSharing1.png -------------------------------------------------------------------------------- /Core/Loyc.Collections/VLists/Diagrams/VListSharing2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/Loyc.Collections/VLists/Diagrams/VListSharing2.png -------------------------------------------------------------------------------- /Core/Loyc.Collections/VLists/Diagrams/WList.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/Loyc.Collections/VLists/Diagrams/WList.png -------------------------------------------------------------------------------- /Core/Loyc.Collections/VLists/Diagrams/WListImmutification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/Loyc.Collections/VLists/Diagrams/WListImmutification.png -------------------------------------------------------------------------------- /Core/Loyc.Collections/VLists/Diagrams/WListRemutification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/Loyc.Collections/VLists/Diagrams/WListRemutification.png -------------------------------------------------------------------------------- /Core/Loyc.Essentials/Collections/Adapters/DictionaryAsSink.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Loyc.Collections 8 | { 9 | partial class DictionaryExt 10 | { 11 | /// Adapts a dictionary to the interface. 12 | public static IDictionarySink AsSink(this IDictionary dict) => new DictionaryAsSink>(dict); 13 | } 14 | 15 | /// Helps implement extension method . 16 | public class DictionaryAsSink : CollectionAsSink, Dict>, IDictionarySink where Dict : IDictionary 17 | { 18 | public DictionaryAsSink(Dict dict) : base(dict) { } 19 | 20 | public V this[K key] { set => _obj[key] = value; } 21 | 22 | public void Add(K key, V value) => _obj.Add(key, value); 23 | 24 | public bool Remove(K key) => _obj.Remove(key); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Loyc.Essentials/Collections/Adapters/ListAsSink.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Loyc.Collections 8 | { 9 | partial class ListExt 10 | { 11 | /// Adapts a list to the interface. 12 | public static IListSink AsSink(this IList list) => new ListAsSink>(list); 13 | public static ICollectionSink AsSink(this ICollection list) => new CollectionAsSink>(list); 14 | } 15 | 16 | /// Helps implement extension method . 17 | public class CollectionAsSink : WrapperBase, ICollectionSink where List : ICollection 18 | { 19 | public CollectionAsSink(List list) : base(list) { } 20 | 21 | public void Add(T item) => _obj.Add(item); 22 | 23 | public void Clear() => _obj.Clear(); 24 | 25 | public bool Remove(T item) => _obj.Remove(item); 26 | } 27 | 28 | /// Helps implement extension method . 29 | public class ListAsSink : CollectionAsSink, IListSink where List : IList 30 | { 31 | public ListAsSink(List list) : base(list) { } 32 | 33 | public T this[int index] { set => _obj[index] = value; } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Core/Loyc.Essentials/Collections/Adapters/ReverseBinumerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Loyc.Collections 7 | { 8 | /// Adapter: a that swaps the MoveNext() and MovePrev() methods. 9 | public struct ReverseBinumerator : IBinumerator 10 | { 11 | IBinumerator _e; 12 | public ReverseBinumerator(IBinumerator realEnumerator) 13 | { 14 | _e = realEnumerator; 15 | } 16 | public bool MovePrev() 17 | { 18 | return _e.MoveNext(); 19 | } 20 | public bool MoveNext() 21 | { 22 | return _e.MovePrev(); 23 | } 24 | public T Current 25 | { 26 | get { return _e.Current; } 27 | } 28 | void IDisposable.Dispose() { _e.Dispose(); } 29 | object System.Collections.IEnumerator.Current { get { return _e.Current; } } 30 | public void Reset() { _e.Reset(); } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Core/Loyc.Essentials/Collections/Adapters/ReversedListSource.cs: -------------------------------------------------------------------------------- 1 | using Loyc.Collections.Impl; 2 | /* 3 | * Created by SharpDevelop. 4 | * User: Pook 5 | * Date: 4/10/2011 6 | * Time: 9:06 AM 7 | * 8 | * To change this template use Tools | Options | Coding | Edit Standard Headers. 9 | */ 10 | using System; 11 | using System.Collections.Generic; 12 | 13 | namespace Loyc.Collections 14 | { 15 | /// Adapter: reversed view of returned 16 | /// from . 17 | [Serializable] 18 | public class ReversedListSource : ListSourceBase 19 | { 20 | IListSource _list; 21 | public ReversedListSource(IListSource list) { _list = list; } 22 | 23 | public IListSource OriginalList { get { return _list; } } 24 | 25 | public new T this[int index] 26 | { 27 | get { return _list[_list.Count - 1 - index]; } 28 | } 29 | public sealed override T TryGet(int index, out bool fail) 30 | { 31 | return _list.TryGet(_list.Count - 1 - index, out fail); 32 | } 33 | public sealed override int Count 34 | { 35 | get { return _list.Count; } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Core/Loyc.Essentials/Collections/BaseClasses/CollectionWrapper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Loyc.Collections.Impl 9 | { 10 | /// A simple base class that helps you use the decorator pattern on a collection. 11 | /// By default, all it does is forward every method to the underlying collection 12 | /// (including GetHashCode, Equals and ToString). You can change its behavior by 13 | /// overriding methods. 14 | /// This could be used, for example, to help you implement a collection 15 | /// that needs to take some kind of action whenever the collection is modified. 16 | /// 17 | /// 18 | public class CollectionWrapper : WrapperBase, ICollection where TCollection : ICollection 19 | { 20 | public CollectionWrapper(TCollection collection) : base(collection) { } 21 | 22 | protected TCollection Collection => _obj; 23 | 24 | public virtual void Add(T item) => _obj.Add(item); 25 | public virtual void Clear() => _obj.Clear(); 26 | public virtual bool Remove(T item) => _obj.Remove(item); 27 | 28 | public bool IsEmpty => Count == 0; 29 | public virtual int Count => _obj.Count; 30 | public virtual bool IsReadOnly => _obj.IsReadOnly; 31 | public virtual bool Contains(T item) => _obj.Contains(item); 32 | public virtual void CopyTo(T[] array, int arrayIndex) => _obj.CopyTo(array, arrayIndex); 33 | public virtual IEnumerator GetEnumerator() => _obj.GetEnumerator(); 34 | IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Core/Loyc.Essentials/Collections/BaseClasses/EnumeratorBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Loyc.Collections 7 | { 8 | /// Base class to help you implement the standard IEnumerator{T} 9 | /// interface. All you have to do is override MoveNext() and, when successful, 10 | /// set the Current property. 11 | public abstract class EnumeratorBase : IEnumerator 12 | { 13 | public abstract bool MoveNext(); 14 | private T _current; 15 | public T Current 16 | { 17 | get { return _current; } 18 | protected set { _current = value; } 19 | } 20 | public void Dispose() 21 | { 22 | } 23 | object System.Collections.IEnumerator.Current 24 | { 25 | get { return Current; } 26 | } 27 | public void Reset() 28 | { 29 | throw new NotSupportedException(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Core/Loyc.Essentials/Collections/BaseClasses/ListWrapper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Loyc.Collections; 7 | 8 | namespace Loyc.Collections.Impl 9 | { 10 | /// A simple base class that to helps you implement a "smart" collection. 11 | /// By default, all it does is forward every method to the underlying collection 12 | /// (including GetHashCode, Equals and ToString). You can change its behavior by 13 | /// overriding methods. 14 | /// This could be used, for example, to help you implement a collection 15 | /// that needs to take some kind of action whenever the collection is modified. 16 | /// 17 | public abstract class ListWrapper : CollectionWrapper, IListAndListSource where TList : IList 18 | { 19 | public ListWrapper(TList wrappedObject) : base(wrappedObject) { } 20 | 21 | public virtual T this[int index] 22 | { 23 | get => _obj[index]; 24 | set => _obj[index] = value; 25 | } 26 | 27 | public virtual void Insert(int index, T item) => _obj.Insert(index, item); 28 | public virtual void RemoveAt(int index) => _obj.RemoveAt(index); 29 | 30 | public virtual int IndexOf(T item) => _obj.IndexOf(item); 31 | public virtual IListSource Slice(int start, int count = int.MaxValue) => new ListSlice(_obj, start, count); 32 | public virtual T TryGet(int index, out bool fail) => (fail = (uint)index >= (uint)_obj.Count) ? default(T) : _obj[index]; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Core/Loyc.Essentials/Collections/ExtensionMethods/ICollectionExt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Loyc.Collections.MutableListExtensionMethods 8 | { 9 | /// Extension methods for . 10 | public static class ICollectionExt 11 | { 12 | /// Adds data to a set (set.Add(value) for all values in a sequence.) 13 | public static void AddRange(this ICollection set, IEnumerable list) 14 | { 15 | foreach (var item in list) 16 | set.Add(item); 17 | } 18 | 19 | /// Removes data from a set (set.Remove(value) for all values in a sequence.) 20 | /// The number of items removed (that had been present in the set). 21 | public static int RemoveRange(this ICollection set, IEnumerable list) 22 | { 23 | int removed = 0; 24 | foreach (var item in list) 25 | if (set.Remove(item)) 26 | removed++; 27 | return removed; 28 | } 29 | 30 | /// Maps a list to an array of the same length. 31 | public static R[] SelectArray(this ICollection input, Func selector) 32 | { 33 | if (input == null) 34 | return null; 35 | R[] result = new R[input.Count]; 36 | var e = input.GetEnumerator(); 37 | for (int i = 0; i < result.Length; i++) 38 | { 39 | e.MoveNext(); 40 | result[i] = selector(e.Current); 41 | } 42 | return result; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Core/Loyc.Essentials/Collections/ExtensionMethods/IPush, IPop.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Loyc.Collections 8 | { 9 | public static partial class IPopExt 10 | { 11 | public static T Pop(this ITryPop c) 12 | { 13 | bool isEmpty; 14 | T next = c.TryPop(out isEmpty); 15 | if (isEmpty) 16 | throw new EmptySequenceException("The {0} is empty".Localized(MemoizedTypeName.Get(c.GetType()))); 17 | return next; 18 | } 19 | public static T Peek(this ITryPop c) 20 | { 21 | bool isEmpty; 22 | T next = c.TryPeek(out isEmpty); 23 | if (isEmpty) 24 | throw new EmptySequenceException("The {0} is empty".Localized(MemoizedTypeName.Get(c.GetType()))); 25 | return next; 26 | } 27 | [Obsolete("Please call a different overload. The return type on this method should be Maybe in the future.")] 28 | public static T TryPop(this ITryPop c) 29 | { 30 | bool isEmpty; 31 | return c.TryPop(out isEmpty); 32 | } 33 | [Obsolete("Please call a different overload. The return type on this method should be Maybe in the future.")] 34 | public static T TryPeek(this ITryPop c) 35 | { 36 | bool isEmpty; 37 | return c.TryPeek(out isEmpty); 38 | } 39 | public static T TryPop(this ITryPop c, T defaultValue) 40 | { 41 | bool isEmpty; 42 | T value = c.TryPop(out isEmpty); 43 | return isEmpty ? defaultValue : value; 44 | } 45 | public static T TryPeek(this ITryPop c, T defaultValue) 46 | { 47 | bool isEmpty; 48 | T value = c.TryPeek(out isEmpty); 49 | return isEmpty ? defaultValue : value; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Core/Loyc.Essentials/Collections/HelperClasses/EmptyArray.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Loyc.Collections 7 | { 8 | /// lets you avoid allocating an empty array on the heap. 9 | public class EmptyArray 10 | { 11 | public static readonly T[] Value = new T[0]; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Core/Loyc.Essentials/Collections/HelperClasses/EmptyEnumerator.cs: -------------------------------------------------------------------------------- 1 | // This file is part of the Loyc project. Licence: LGPL 2 | using System; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | 6 | namespace Loyc.Collections 7 | { 8 | /// Helper class: an empty enumerator. 9 | [Serializable] 10 | public class EmptyEnumerator : IEnumerator, IEnumerator 11 | { 12 | public static readonly IEnumerator Value = new EmptyEnumerator(); 13 | 14 | public T Current { get { return default(T); } } 15 | object IEnumerator.Current { get { return this.Current; } } 16 | public void Dispose() { } 17 | public bool MoveNext() { return false; } 18 | public void Reset() { } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Core/Loyc.Essentials/Collections/HelperClasses/EmptyList.cs: -------------------------------------------------------------------------------- 1 | // This file is part of the Loyc project. Licence: LGPL 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Loyc.Collections 7 | { 8 | /// Helper class: is a read-only empty list. 9 | /// It is a boxed copy of ListExt.Repeat(default(T), 0). 10 | [Serializable] 11 | public static class EmptyList 12 | { 13 | public static readonly IListAndListSource Value = new Repeated(default(T), 0); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Core/Loyc.Essentials/Collections/HelperClasses/RangeEnumerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Loyc; 6 | 7 | namespace Loyc.Collections 8 | { 9 | /// Helper struct: enumerates through a forward range (). 10 | /// 11 | [Obsolete("Not in use. If you are using this, please leave an issue at https://github.com/qwertie/ecsharp/ to have the deprecation cancelled.")] 12 | public struct RangeEnumerator : IEnumerator 13 | { 14 | IFRange _range; 15 | T _current; 16 | public RangeEnumerator(IFRange range) { _range = range.Clone(); _current = default(T); } 17 | 18 | public bool MoveNext() { bool empty; _current = _range.PopFirst(out empty); return !empty; } 19 | public T Current { get { return _current; } } 20 | 21 | object System.Collections.IEnumerator.Current { get { return Current; } } 22 | void IDisposable.Dispose() { } 23 | void System.Collections.IEnumerator.Reset() { throw new NotSupportedException(); } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Core/Loyc.Essentials/Collections/HelperClasses/ReverseComparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Loyc.Collections 7 | { 8 | /// Reverses the order used by an IComparer object. 9 | public struct ReverseComparer : IComparer 10 | { 11 | IComparer _comparer; 12 | public ReverseComparer(IComparer comparer) 13 | { 14 | _comparer = comparer; 15 | } 16 | public int Compare(T x, T y) 17 | { 18 | return _comparer.Compare(y, x); 19 | } 20 | } 21 | 22 | /// Reverses the order used by an IComparer object. 23 | public struct ReverseComparer : IComparer where TComparer : IComparer 24 | { 25 | TComparer _comparer; 26 | public ReverseComparer(TComparer comparer) 27 | { 28 | _comparer = comparer; 29 | } 30 | public int Compare(T x, T y) 31 | { 32 | return _comparer.Compare(y, x); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Core/Loyc.Essentials/Collections/HelperClasses/SelectCollection.ecs: -------------------------------------------------------------------------------- 1 | using Loyc.Collections.Impl; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | 6 | namespace Loyc.Collections 7 | { 8 | define GenerateSelectClass($SelectCollection, $ICollection) 9 | { 10 | /// Helper class for . 11 | public class $SelectCollection 12 | : ReadOnlyCollectionBase where ListT : $ICollection 13 | { 14 | public this(protected ListT _list, protected Func _selector) { 15 | if (_list == null || _selector == null) 16 | throw new ArgumentNullException(); 17 | } 18 | 19 | public sealed override IEnumerator GetEnumerator() 20 | { 21 | return Enumerable.Select(_list, _selector).GetEnumerator(); 22 | } 23 | public sealed override int Count 24 | { 25 | get { return _list.Count; } 26 | } 27 | } 28 | } 29 | 30 | GenerateSelectClass(SelectCollection, ICollection); 31 | 32 | GenerateSelectClass(SelectReadOnlyCollection, IReadOnlyCollection); 33 | } 34 | -------------------------------------------------------------------------------- /Core/Loyc.Essentials/Compatibility/WeakReference.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Runtime.Serialization; 6 | 7 | namespace Loyc 8 | { 9 | /// The new type in .NET 4.5 removes 10 | /// the Target and IsAlive properties. These extension methods 11 | /// restore that traditional functionality, making it easier to transition 12 | /// from the old WeakReference to the new one. 13 | public static class WeakReferenceExt 14 | { 15 | public static T Target(this WeakReference r) where T:class 16 | { 17 | T t; 18 | r.TryGetTarget(out t); 19 | return t; 20 | } 21 | public static bool IsAlive(this WeakReference r) where T : class 22 | { 23 | T _; 24 | return r.TryGetTarget(out _); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Core/Loyc.Essentials/MessageSinks/LogException.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Miscellaneous small items related to message sinks 3 | // 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | 9 | namespace Loyc 10 | { 11 | /// An exception that includes a "context" object as part of a 12 | /// structure, typically used to indicate where an 13 | /// error occurred. 14 | public class LogException : Exception 15 | { 16 | public LogException(object context, string format, params object[] args) : this(Severity.Error, context, format, args) {} 17 | public LogException(Severity severity, object context, string format, params object[] args) : this(new LogMessage(severity, context, format, args)) {} 18 | public LogException(LogMessage msg) { 19 | Msg = msg; 20 | try { 21 | Data["Severity"] = msg.Severity; 22 | // Disabled because members of the Data dictionary must be serializable, 23 | // but msg.Context might not be. We could convert to string, but is it 24 | // worth the performance cost? Loyc code isn't really using Data anyway. 25 | //Data["Context"] = msg.Context; 26 | } catch { } 27 | } 28 | 29 | /// Contains additional information about the error that occurred. 30 | public LogMessage Msg { get; private set; } 31 | 32 | public override string Message 33 | { 34 | get { return Msg.Formatted; } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Core/Loyc.Essentials/MessageSinks/LogMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Loyc.Collections; 7 | 8 | namespace Loyc 9 | { 10 | /// Holds an argument list compatible with 11 | /// . 12 | /// Typically used with . 13 | public struct LogMessage : ILocation, ILogMessage 14 | { 15 | public LogMessage(Severity type, object context, string format, object arg0, object arg1 = null) 16 | : this (type, context, format, new object[2] { arg0, arg1 }) {} 17 | public LogMessage(Severity type, object context, string format) 18 | : this (type, context, format, EmptyArray.Value) {} 19 | public LogMessage(Severity type, object context, string format, params object[] args) 20 | { 21 | Severity = type; 22 | Context = context; 23 | Format = format; 24 | _args = args; 25 | } 26 | 27 | public Severity Severity { get; set; } 28 | public object Context { get; set; } 29 | public string Format { get; set; } 30 | object[] _args; 31 | public object[] Args { get => _args; set => _args = value; } 32 | public string Formatted 33 | { 34 | get { 35 | try { 36 | return Localize.Localized(Format, _args); 37 | } catch { 38 | return Format; 39 | } 40 | } 41 | } 42 | 43 | public override string ToString() 44 | { 45 | return MessageSink.FormatMessage(Severity, Context, Format, _args); 46 | } 47 | 48 | public object Location 49 | { 50 | get { return MessageSink.LocationOf(Context); } 51 | } 52 | public void WriteTo(IMessageSink sink) 53 | { 54 | if (_args.Length == 0) 55 | sink.Write(Severity, Context, Format); 56 | else 57 | sink.Write(Severity, Context, Format, _args); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Core/Loyc.Essentials/MessageSinks/MessageHolder.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Defines MessageHolder and the LogMessage structure that it depends on 3 | // 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using Loyc.Collections; 8 | 9 | namespace Loyc 10 | { 11 | /// A message sink that puts the messages it receives in a list. 12 | public class MessageHolder : IMessageSink, ICloneable 13 | { 14 | List _messages; 15 | 16 | public IList List 17 | { 18 | get { return _messages = _messages ?? new List(); } 19 | } 20 | 21 | public void WriteListTo(IMessageSink sink) 22 | { 23 | foreach (LogMessage msg in List) 24 | msg.WriteTo(sink); 25 | } 26 | 27 | public void Write(Severity level, object context, string format) 28 | { 29 | List.Add(new LogMessage(level, context, format)); 30 | } 31 | public void Write(Severity level, object context, string format, object arg0, object arg1 = null) 32 | { 33 | List.Add(new LogMessage(level, context, format, arg0, arg1)); 34 | } 35 | public void Write(Severity level, object context, string format, params object[] args) 36 | { 37 | List.Add(new LogMessage(level, context, format, args)); 38 | } 39 | /// Always returns true. 40 | public bool IsEnabled(Severity level) 41 | { 42 | return true; 43 | } 44 | 45 | public MessageHolder Clone() 46 | { 47 | var copy = new MessageHolder(); 48 | if (_messages != null) 49 | copy._messages = new List(_messages); 50 | return copy; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Core/Loyc.Essentials/OpenSourceKey.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/Loyc.Essentials/OpenSourceKey.snk -------------------------------------------------------------------------------- /Core/Loyc.Essentials/Utilities/Holder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Loyc 8 | { 9 | /// A trivial class that holds a single value of type T in the 10 | /// property. 11 | /// 12 | /// This class is useful mainly as an alternative to standard boxing. When you 13 | /// box a structure in C#, you lose access to the members of that structure. 14 | /// This class, in contrast, provides access to the "boxed" value. 15 | /// This type is different from the standard Tuple{T} in that the 16 | /// is a mutable field. 17 | /// 18 | public class Holder : IMValue 19 | { 20 | public Holder(T value) { Value = value; } 21 | public Holder() { } 22 | 23 | /// Any value of type T. 24 | public T Value; 25 | T IValue.Value { get { return Value; } } 26 | T IMValue.Value { get { return Value; } set { Value = value; } } 27 | 28 | public override bool Equals(object obj) 29 | { 30 | if (obj is Holder) 31 | obj = ((Holder)obj).Value; 32 | return Value == null ? obj == null : Value.Equals(obj); 33 | } 34 | public override int GetHashCode() => Value == null ? 0 : Value.GetHashCode(); 35 | public override string ToString() => Value?.ToString(); 36 | public static implicit operator Holder(T value) { return new Holder(value); } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Core/Loyc.Essentials/Utilities/SavedValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Threading; 4 | 5 | namespace Loyc.Threading 6 | { 7 | /// 8 | /// Designed to be used in a "using" statement to temporarily alter a 9 | /// or 10 | /// or something else implementing . 11 | /// 12 | public struct SavedValue : IDisposable 13 | { 14 | readonly T _oldValue; 15 | readonly IMValue _valueHolder; 16 | 17 | public SavedValue(IMValue oldValue, T newValue) 18 | { 19 | _valueHolder = oldValue; 20 | _oldValue = oldValue.Value; 21 | oldValue.Value = newValue; 22 | } 23 | public void Dispose() 24 | { 25 | _valueHolder.Value = _oldValue; 26 | } 27 | 28 | public T OldValue { get { return _oldValue; } } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Loyc.Essentials/Utilities/WrapperBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Loyc 6 | { 7 | /// Abstract class that helps you implement wrappers by automatically 8 | /// forwarding calls to Equals(), GetHashCode() and ToString(). 9 | [Serializable] 10 | public abstract class WrapperBase 11 | { 12 | protected T _obj; 13 | protected WrapperBase(T wrappedObject) => _obj = wrappedObject; // possibly null 14 | 15 | protected static readonly EqualityComparer TComp = EqualityComparer.Default; 16 | 17 | /// Returns true iff the parameter 'obj' is a wrapper around an object that 18 | /// is equal to the object that this object wraps. 19 | /// The object to compare with the current object. 20 | /// If obj actually refers to the wrapped object, this method returns 21 | /// false to preserve commutativity of the "Equals" relation. 22 | public override bool Equals(object obj) 23 | { 24 | var w = obj as WrapperBase; 25 | return w != null && TComp.Equals(_obj, w._obj); 26 | } 27 | /// Returns the hashcode of the wrapped object. 28 | public override int GetHashCode() 29 | { 30 | return TComp.GetHashCode(_obj); 31 | } 32 | /// Returns ToString() of the wrapped object. 33 | public override string ToString() 34 | { 35 | return _obj.ToString(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Core/Loyc.Essentials/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Core/Loyc.Essentials/void.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Loyc 7 | { 8 | /// @void.Value represents the sole value of System.Void 9 | /// (called "void" in C#). 10 | /// .NET unfortunately treats void as something that is not a real 11 | /// type; for example you cannot use new void() or default(void) 12 | /// in C#. This was a dumb decision because it means that some generic code 13 | /// must be duplicated for void and non-void types. A good example is the fact 14 | /// that when you have a , TVal cannot be 15 | /// void, so you cannot use Dictionary(string,void) to express the idea 16 | /// of "a set of strings with no associated values". The 17 | /// class uses a completely separate implementation and cannot just be an 18 | /// alias for Dictionary{T,void} (actually they could share 19 | /// implementations using a dummy type like this one, but unfortunately .NET 20 | /// made another dumb decision that all types must consume at least one byte, 21 | /// so HashSet sharing code with Dictionary would make 22 | /// HashSet less efficient.) 23 | /// 24 | /// Defining a @void type allows you to use it when it makes conceptual sense, 25 | /// although we cannot avoid .NET's requirement to waste at least one byte. 26 | /// 27 | public struct @void 28 | { 29 | public static readonly @void Value = new @void(); 30 | public override string ToString() 31 | { 32 | return "void"; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Core/Loyc.Interfaces.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Loyc.Interfaces 5 | $version$ 6 | David Piepgrass 7 | David Piepgrass 8 | http://core.loyc.net 9 | 10 | Readme.md 11 | false 12 | Interfaces implemented in other Loyc Core libraries 13 | A library of interfaces, enums, and delegates that are useful in a broad range of software projects, according to the theme "things that should be built into the .NET framework, but aren’t". 14 | 15 | Also contains a small number of essential structs and classes, most notably Symbol, UString, Maybe<T>, and Localize. These are types that the interfaces refer to, or that the concrete types themselves depend on. 16 | See http://core.loyc.net/version-history 17 | Copyright 2020 18 | Loyc Core Interfaces Collections 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /Core/Loyc.Interfaces/Collections/IAutoCreatePool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Loyc.Collections 7 | { 8 | /// Represents a pool of objects in which an object is 9 | /// automatically created when requested by its key. 10 | /// Key type. 11 | /// Value type. 12 | /// This design assumes that the values in the pool know their own 13 | /// key, so it implements IEnumerable{TValue} rather than 14 | /// IEnumerable{KeyValuePair{TKey,TValue}}. 15 | public interface IAutoCreatePool : IReadOnlyCollection 16 | { 17 | /// Gets or creates the value associated with the specified key. 18 | /// The key was not valid 19 | /// for this list. 20 | /// A key object. 21 | /// The associated value object, which is created automatically 22 | /// if it does not already exist. 23 | TValue this[TKey key] { get; } 24 | 25 | /// Gets the item with the specified key, if it was created earlier. 26 | /// The value corresponding to the specified key, or 27 | /// default(TValue) if the value has not been created. 28 | TValue GetIfExists(TKey key); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Loyc.Interfaces/Collections/ITuple.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace Loyc.Compatibility 4 | { 5 | #if NetStandard20 || DotNet45 6 | 7 | /// Defines ITuple in .NET Standard 2.0. System.Runtime.CompilerServices.ITuple 8 | /// was added to .NET Core 2.0 and .NET Framework 4.7.1, but it wasn't added to .NET 9 | /// Standard 2.0. ITuple was added to .NET Standard 2.1, but this requires .NET Core 3. 10 | public interface ITuple 11 | { 12 | object this[int index] { get; } 13 | int Length { get; } 14 | } 15 | 16 | #else 17 | 18 | /// Ensure `using Loyc.Compatibility` is not an error 19 | public interface __ThisEnsuresTheNamespaceIsNotEmpty { } 20 | 21 | #endif 22 | } 23 | -------------------------------------------------------------------------------- /Core/Loyc.Interfaces/Concrete/EmptySourceFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using Loyc.Collections; 5 | 6 | namespace Loyc.Syntax 7 | { 8 | /// 9 | /// A dummy implementation of that has only a 10 | /// filename, no source text. Used as the source file of synthetic syntax 11 | /// nodes. 12 | /// 13 | public class EmptySourceFile : ISourceFile 14 | { 15 | [Obsolete("Please use another instance, such as Synthetic or Unknown")] 16 | public static readonly EmptySourceFile Default = new EmptySourceFile(""); 17 | public static readonly EmptySourceFile Synthetic = new EmptySourceFile("".Localized()); 18 | public static readonly EmptySourceFile Unknown = new EmptySourceFile("".Localized()); 19 | 20 | public EmptySourceFile(string fileName) 21 | { 22 | _fileName = fileName; 23 | } 24 | 25 | private string _fileName; 26 | public string FileName 27 | { 28 | get { return _fileName; } 29 | } 30 | 31 | public ICharSource Text 32 | { 33 | get { return UString.Null; } 34 | } 35 | 36 | ILineColumnFile IIndexToLine.IndexToLine(int index) => IndexToLine(index); 37 | public LineColumnFile IndexToLine(int index) 38 | { 39 | return LineColumnFile.Nowhere; 40 | } 41 | public int LineToIndex(int lineNo) 42 | { 43 | return -1; 44 | } 45 | public int LineToIndex(ILineAndColumn pos) 46 | { 47 | return -1; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Core/Loyc.Interfaces/Concrete/NoValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Loyc 7 | { 8 | /// NoValue.Value is meant to be used as the value of a 9 | /// property that has "no value", meaning no value is assigned or that the 10 | /// property is meaningless at the current time or in the current context. 11 | /// 12 | /// Most often null is used for this purpose; NoValue.Value 13 | /// is used when null is (or might be) a valid, meaningful 14 | /// value and you want to distinguish between "no value" and "null". 15 | /// For example, this can be returned by the Value property of , 16 | /// in which NoValue means "this is not a literal, so it can't have 17 | /// a value, not even null". 18 | /// 19 | /// Also, this value converts implicitly to . 20 | /// 21 | public class NoValue 22 | { 23 | private NoValue() { } 24 | public static readonly NoValue Value = new NoValue(); 25 | public override string ToString() 26 | { 27 | return "(No value)".Localized(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Loyc.Interfaces/Concrete/RangeEnumerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Loyc; 6 | 7 | namespace Loyc.Collections 8 | { 9 | /// Helper struct: enumerates through a forward range (), 10 | /// calling the range methods through R instead of through . 11 | /// 12 | public struct RangeEnumerator : IEnumerator where R : IFRange, ICloneable 13 | { 14 | R _range; 15 | T _current; 16 | public RangeEnumerator(R range) { _range = R_Clone(range); _current = default(T); } 17 | 18 | public bool MoveNext() { bool empty; _current = _range.PopFirst(out empty); return !empty; } 19 | public T Current { get { return _current; } } 20 | 21 | object System.Collections.IEnumerator.Current { get { return Current; } } 22 | void IDisposable.Dispose() { } 23 | void System.Collections.IEnumerator.Reset() { throw new NotSupportedException(); } 24 | 25 | /// Since R implements IFRange{T} which includes ICloneable{IFRange{T}}, 26 | /// we cannot invoke ICloneable{R}.Clone because the compiler complains that 27 | /// Clone() is ambiguous. I used to think it was necessary to cast the range to just to clone it; if R is a value type then it is 29 | /// boxed, hurting performance. But then I thought of doing this. 30 | static R_ R_Clone(R_ r) where R_ : ICloneable => r.Clone(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Core/Loyc.Interfaces/Concrete/SavedThreadLocal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | 4 | namespace Loyc.Threading 5 | { 6 | /// 7 | /// Designed to be used in a "using" statement to temporarily alter a 8 | /// . 9 | /// 10 | public struct SavedThreadLocal : IDisposable 11 | { 12 | T _oldValue; 13 | ThreadLocal _variable; 14 | 15 | public SavedThreadLocal(ThreadLocal variable, T newValue) 16 | { 17 | _variable = variable; 18 | _oldValue = variable.Value; 19 | variable.Value = newValue; 20 | } 21 | public void Dispose() 22 | { 23 | _variable.Value = _oldValue; 24 | } 25 | 26 | public T OldValue { get { return _oldValue; } } 27 | public T Value { get { return _variable.Value; } } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Core/Loyc.Interfaces/ILocation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Loyc 7 | { 8 | /// This interface allows an object to declare its "location". 9 | /// 10 | /// Objects designed to be used as a context parameter in 11 | /// can implement this interface so that the string form of the message shows 12 | /// the location of a piece of data instead of the data itself. For example, 13 | /// implements this interface so that when a 14 | /// compiler error refers to a source code construct, the context of the 15 | /// can refer to the code itself while the printed form 16 | /// of the the error message shows the location of the code instead. 17 | /// 18 | /// Given a context object that may or may not implement this interface, it's 19 | /// handy to use to convert the 20 | /// "context" of a message into a string, or 21 | /// to unwrap objects that implement ILocation. 22 | /// 23 | public interface ILocation 24 | { 25 | object Location { get; } 26 | } 27 | 28 | [Obsolete("This was renamed to ILocation")] 29 | public interface IHasLocation : ILocation { } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Loyc.Interfaces/ILogMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Loyc 8 | { 9 | /// A formatted message with an associated Context. 10 | /// 11 | public interface ILogMessage 12 | { 13 | /// Indicates how problematic the message is (Debug, Note, Warning, Error, etc.) 14 | Severity Severity { get; } 15 | /// An object associated with the event being logged (possibly huge). 16 | object Context { get; } 17 | /// Format string (without substitutions or localization) 18 | string Format { get; } 19 | /// Values to be substituted into the format string. 20 | object[] Args { get; } 21 | /// Formatted string (with substitution and localization applied) 22 | string Formatted { get; } 23 | /// Typically this returns MessageSink.LocationOf(Context). 24 | object Location { get; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Loyc.Interfaces/Loyc.Interfaces.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netstandard2.0 4 | ..\Bin\$(Configuration)\ 5 | 1591, 1573, 0419, 1587, 1574 6 | true 7 | OpenSourceKey.snk 8 | false 9 | 10 | 11 | true 12 | ..\Bin\$(Configuration)\$(TargetFramework)\Loyc.Interfaces.xml 13 | 14 | 15 | TRACE;NetStandard20 16 | 17 | 18 | TRACE;NetStandard20 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Core/Loyc.Interfaces/Misc.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Loyc 7 | { 8 | /// This is the method signature of IMessageSink.Write(). You 9 | /// can convert from one of these delegates to by 10 | /// calling . 11 | /// Severity or importance of the message; widely-used 12 | /// types include Error, Warning, Note, Debug, and Verbose. The special 13 | /// type Detail is intended to provide more information about a previous 14 | /// message. 15 | /// An object that represents the location that the 16 | /// message applies to, a string that indicates what the program was doing 17 | /// when the message was generated, or any other relevant context information. 18 | /// See also (). 19 | /// A message to display. If there are additional 20 | /// arguments, placeholders such as {0} and {1} refer to these arguments. 21 | /// Optional arguments to fill in placeholders in the format 22 | /// string. 23 | public delegate void WriteMessageFn(Severity type, object context, string format, params object[] args); 24 | } 25 | -------------------------------------------------------------------------------- /Core/Loyc.Interfaces/OpenSourceKey.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/Loyc.Interfaces/OpenSourceKey.snk -------------------------------------------------------------------------------- /Core/Loyc.Interfaces/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | #region Using directives 2 | 3 | using System; 4 | using System.Reflection; 5 | using System.Runtime.CompilerServices; 6 | using System.Runtime.InteropServices; 7 | 8 | #endregion 9 | 10 | // General Information about an assembly is controlled through the following 11 | // set of attributes. Change these attribute values to modify the information 12 | // associated with an assembly. 13 | [assembly: AssemblyTitle("Loyc.Interfaces")] 14 | [assembly: AssemblyDescription("A library of interfaces used in the Loyc Core libraries. "+ 15 | "Also contains a small number of essential structs, attribute types, enums, and delegates.")] 16 | [assembly: AssemblyConfiguration("")] 17 | [assembly: AssemblyCompany("David Piepgrass")] 18 | [assembly: AssemblyProduct("Loyc.Interfaces")] 19 | [assembly: AssemblyTrademark("")] 20 | [assembly: AssemblyCulture("")] 21 | 22 | // This sets the default COM visibility of types in the assembly to invisible. 23 | // If you need to expose a type to COM, use [ComVisible(true)] on that type. 24 | [assembly: ComVisible(false)] 25 | 26 | [assembly: CLSCompliant(false)] 27 | 28 | //[assembly: InternalsVisibleTo("LoycCore.Tests")] is not allowed in a signed assembly 29 | [assembly: InternalsVisibleTo("LoycCore.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100adec5c8e52098b94dc60b34ac0916d307eec23b2c285a0beeb7168174fc1f6a71dcae43c88904e2907a12f66861de8d8f130c4f7b57cff0aea92ed06b50d96c63cea2ee19ec5d35a2946ddef3f35f0fbd3ec3a358b46fd05c82837c49d91694c1926935dc83e2a28c1ff077e4d8a5f679f1edb1c8a692aa2913d753ea05f4fba")] 30 | -------------------------------------------------------------------------------- /Core/Loyc.Interfaces/Syntax/ILineColumnFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Loyc.Syntax 4 | { 5 | public interface IFileName 6 | { 7 | string FileName { get; } 8 | } 9 | 10 | [Obsolete("This was renamed to IFileName")] 11 | public interface IHasFileName : IFileName { } 12 | 13 | /// A line/column pair representing a location in a text file. 14 | /// Numbering starts at one for both Line and Column. 15 | public interface ILineAndColumn 16 | { 17 | int Line { get; } 18 | int Column { get; } 19 | } 20 | public interface ILineColumnFile : ILineAndColumn, IFileName { } 21 | } 22 | -------------------------------------------------------------------------------- /Core/Loyc.Interfaces/Syntax/ILiteralParser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Loyc.Syntax 8 | { 9 | /// This interface for parsing text into objects is implemented by . 10 | public interface ILiteralParser 11 | { 12 | /// Returns true if this object has a parser for the specified type marker. 13 | /// Returns false if typeMarker == null. 14 | bool CanParse(Symbol typeMarker); 15 | 16 | /// Attempts to parse a string with a given type marker. 17 | /// A text value that has already been preprocessed to remove 18 | /// escape sequences. 19 | /// Indicates the type of the value. There is a standard 20 | /// set of type markers; please see the documention of . 21 | /// If typeMarker is null, it is treated as an empty string. 22 | /// 23 | /// Returns either the parsed value or an error message. Does not throw. 24 | /// If the problem is that the type marker doesn't have an associated parser, 25 | /// the returned should not have a Severity of Error; 26 | /// uses for this. 27 | Either TryParse(UString textValue, Symbol typeMarker); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Core/Loyc.Interfaces/Syntax/ILiteralPrinter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Loyc.Syntax 8 | { 9 | /// This interface for converting literals to text is implemented by . 10 | public interface ILiteralPrinter 11 | { 12 | /// Finds out whether there is a printer for the given type marker. Never throws. 13 | /// True if typeMarker is not null and there is a printer for that marker. 14 | bool CanPrint(Symbol typeMarker); 15 | 16 | /// Returns true if there is a printer registered for the given type. Never throws. 17 | /// True if type is not null and if there is a printer for that type. 18 | bool CanPrint(Type type); 19 | 20 | /// Attempts to convert the specified literal to a string. 21 | /// A literal that you want to convert to a string. 22 | /// Either a recommended type marker for the literal, or an error 23 | /// message. The string form of the literal is appended to the StringBuilder 24 | /// provided by the caller. If an error occurs, it is possible that some kind 25 | /// of output was added to the StringBuilder anyway. 26 | /// The string is printed without escaping. For example a newline 27 | /// would be printed as character (char)10, not "\n". 28 | Either TryPrint(ILNode literal, StringBuilder sb); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Loyc.Interfaces/Syntax/ISourceFile.cs: -------------------------------------------------------------------------------- 1 | using Loyc.Collections; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace Loyc.Syntax 8 | { 9 | /// Represents a text file with a file name and its textual content, 10 | /// plus the data necessary to convert between line-column positions and 11 | /// 0-based integer indexes. 12 | public interface ISourceFile : IIndexPositionMapper 13 | { 14 | ICharSource Text { get; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Core/Loyc.Interfaces/Syntax/ISourceRange.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Loyc.Syntax 7 | { 8 | /// Represents a pair of integers that represents a range of indices: 9 | /// either start & end or start & length. Invariant: Length == EndIndex-StartIndex. 10 | public interface IIndexRange 11 | { 12 | int StartIndex { get; } 13 | int EndIndex { get; } 14 | int Length { get; } 15 | } 16 | 17 | /// Represents a (contiguous) region of text in a source file. 18 | public interface ISourceRange : IIndexRange 19 | { 20 | ISourceFile Source { get; } 21 | } 22 | 23 | /// Standard extension methods for . 24 | public static class SourceRangeExt 25 | { 26 | public static UString SourceText(this SourceRange range) where SourceRange : ISourceRange 27 | { 28 | if (range.EndIndex <= range.StartIndex) 29 | return ""; 30 | if (range.StartIndex >= range.Source.Text.Count) 31 | return Localize.Localized(range.Source.Text.Count == 0 ? "(not available)" : "(invalid range)"); 32 | return range.Source.Text.Slice(range.StartIndex, range.EndIndex - range.StartIndex); 33 | } 34 | public static ILineColumnFile Start(this SourceRange range) where SourceRange : ISourceRange 35 | { 36 | if (range.Source == null) 37 | return LineColumnFile.Nowhere; 38 | return range.Source.IndexToLine(range.StartIndex); 39 | } 40 | public static ILineColumnFile End(this SourceRange range) where SourceRange : ISourceRange 41 | { 42 | if (range.Source == null) 43 | return LineColumnFile.Nowhere; 44 | return range.Source.IndexToLine(range.EndIndex); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Core/Loyc.Math/Geometry/Rectangle3Ext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Loyc.Geometry 7 | { 8 | /// Contains methods to manipulate rectangles. 9 | /// Unfortunately, C# often can't infer the type parameters. Many of 10 | /// these methods must be called with explicit type parameters. 11 | public static class Rectangle3Ext 12 | { 13 | public static bool IsNormal(this Rect r) 14 | where Rect : IRectangle3Reader 15 | where T : IComparable 16 | { 17 | // Hey Microsoft, this would probably be faster if the built-in types 18 | // implemented simple boolean methods: IsLess(), IsLessOrEqual(). 19 | return r.X2.CompareTo(r.X1) >= 0 && r.Y2.CompareTo(r.Y1) >= 0 && r.Z2.CompareTo(r.Z1) >= 0; 20 | } 21 | public static void Normalize(this Rect r) 22 | where Rect : IRectangle3Base 23 | where T : IComparable 24 | { 25 | T z1 = r.X1, z2 = r.X2; 26 | if (r.Z2.CompareTo(r.Z1) < 0) 27 | r.SetZRange(z2, z1); 28 | RectangleExt.Normalize(r); 29 | } 30 | 31 | public static void SetRect(this Rect r, T x, T y, T z, T width, T height, T depth) 32 | where Rect : IRectangle3Base 33 | { 34 | r.SetXAndWidth(x, width); 35 | r.SetYAndHeight(y, height); 36 | r.SetZAndDepth(z, depth); 37 | } 38 | public static void SetRange(this Rect r, T x1, T y1, T z1, T x2, T y2, T z2) 39 | where Rect : IRectangle3Base 40 | { 41 | r.SetXRange(x1, x2); 42 | r.SetYRange(y1, y2); 43 | r.SetZRange(z1, z2); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Core/Loyc.Math/OpenSourceKey.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/Loyc.Math/OpenSourceKey.snk -------------------------------------------------------------------------------- /Core/Loyc.Math/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Loyc.Math")] 9 | [assembly: AssemblyDescription("A math of basic math and geometry with the theme \"things that should be built into the .NET framework, but aren't\".")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("David Piepgrass")] 12 | [assembly: AssemblyProduct("Loyc.Math")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("7493a75d-106a-4a50-9dcf-a7a034629fff")] 23 | -------------------------------------------------------------------------------- /Core/Loyc.Syntax.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Loyc.Syntax 5 | $version$ 6 | David Piepgrass 7 | David Piepgrass 8 | http://core.loyc.net 9 | 10 | Readme.md 11 | false 12 | A parser library. 13 | Loyc.Syntax implements various interfaces and helper classes for Loyc Languages and for users of LLLPG. It also implements Loyc trees for .NET (LNode), and parsers and printers for Loyc Expression Syntax (LES) versions 2 and 3. 14 | See http://core.loyc.net/version-history 15 | Copyright 2020 16 | Loyc Core Parser LES LLLPG 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Core/Loyc.Syntax/LES/Les2PrinterWriter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | using System.Diagnostics; 7 | using Loyc.Collections; 8 | using Loyc.Syntax.Impl; 9 | 10 | namespace Loyc.Syntax.Les 11 | { 12 | internal sealed class Les2PrinterWriter : LNodePrinterHelper 13 | { 14 | public Les2PrinterWriter(StringBuilder sb, string indentString = "\t", string lineSeparator = "\n", string labelIndent = "", Action saveRange = null) 15 | : base(sb, saveRange, false, indentString, lineSeparator, labelIndent, " ", 4) { } 16 | 17 | internal bool JustWroteSymbolOrSpecialId; 18 | 19 | protected override void OnNodeChanged(char nextCh) 20 | { 21 | var lastCh = LastCharWritten; 22 | if (Les2Lexer.IsIdContChar(lastCh) && Les2Lexer.IsIdContChar(nextCh)) 23 | StringBuilder.Append(' '); 24 | else if (Les2Lexer.IsOpContChar(lastCh) && Les2Lexer.IsOpContChar(nextCh)) 25 | StringBuilder.Append(' '); 26 | else if (JustWroteSymbolOrSpecialId && Les2Lexer.IsSpecialIdChar(nextCh)) 27 | StringBuilder.Append(' '); 28 | 29 | JustWroteSymbolOrSpecialId = false; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Core/Loyc.Syntax/LNodes/ILiteralValueProvider.cs: -------------------------------------------------------------------------------- 1 | namespace Loyc.Syntax 2 | { 3 | /// The intention of this interface is that a struct implementing 4 | /// it can be embedded inside a in order to lazily obtain 5 | /// the text of a literal, or even parse it lazily. 6 | /// Each method here is given the value of so that 7 | /// the provider has access to the original source code text. 8 | public interface ILiteralValueProvider 9 | { 10 | /// returns whatever this returns. 11 | object GetValue(SourceRange range); 12 | /// returns whatever this returns. 13 | UString GetTextValue(SourceRange range); 14 | /// returns whatever this returns. 15 | Symbol GetTypeMarker(SourceRange range); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Core/Loyc.Syntax/LNodes/LNodePrintingOptions.cs: -------------------------------------------------------------------------------- 1 | using Loyc.Collections; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace Loyc.Syntax 8 | { 9 | /// A concrete class that users can pass to an . 10 | public class LNodePrinterOptions : ILNodePrinterOptions 11 | { 12 | public virtual bool AllowChangeParentheses { get; set; } 13 | public virtual bool OmitComments { get; set; } 14 | public virtual bool OmitUnknownTrivia { get; set; } 15 | public virtual bool PrintTriviaExplicitly { get; set; } 16 | public virtual bool CompatibilityMode { get; set; } 17 | public virtual bool CompactMode { get; set; } 18 | public virtual string IndentString { get; set; } 19 | public virtual string NewlineString { get; set; } 20 | public virtual ILiteralPrinter LiteralPrinter { get; set; } 21 | public virtual Action SaveRange { get; set; } 22 | 23 | public void CopyFrom(ILNodePrinterOptions original) 24 | { 25 | AllowChangeParentheses = original.AllowChangeParentheses; 26 | OmitComments = original.OmitComments; 27 | OmitUnknownTrivia = original.OmitUnknownTrivia; 28 | PrintTriviaExplicitly = original.PrintTriviaExplicitly; 29 | CompatibilityMode = original.CompatibilityMode; 30 | CompactMode = original.CompactMode; 31 | IndentString = original.IndentString; 32 | NewlineString = original.NewlineString; 33 | LiteralPrinter = original.LiteralPrinter; 34 | SaveRange = original.SaveRange; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Core/Loyc.Syntax/LNodes/LNodeVisitor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Loyc.Syntax 7 | { 8 | /// Base class for people that want to implement the visitor pattern with . 9 | public abstract class LNodeVisitor : ILNodeVisitor 10 | { 11 | public void Visit(LNode node) { node.Call(this); } 12 | public abstract void Visit(IdNode node); 13 | public abstract void Visit(LiteralNode node); 14 | public abstract void Visit(CallNode node); 15 | } 16 | 17 | /// Interface for people that want to implement the visitor pattern with . 18 | /// If your visitor does not need a base class, use as the base class. 19 | public interface ILNodeVisitor 20 | { 21 | void Visit(IdNode node); 22 | void Visit(LiteralNode node); 23 | void Visit(CallNode node); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Core/Loyc.Syntax/LNodes/LiteralValue.cs: -------------------------------------------------------------------------------- 1 | namespace Loyc.Syntax 2 | { 3 | /// Bundles the optional original text of a value with an optional in-memory 4 | /// form of it; see remarks at . 5 | /// This struct can also be turned into an LNode by calling 6 | /// . 7 | /// 8 | public struct LiteralValue : ILiteralValue, ILiteralValueProvider 9 | { 10 | public LiteralValue(object value, Symbol typeMarker, UString textValue = default) 11 | { 12 | Value = value; 13 | TextValue = textValue; 14 | TypeMarker = typeMarker; 15 | } 16 | public object Value { get; } 17 | public UString TextValue { get; } 18 | public Symbol TypeMarker { get; } 19 | 20 | UString ILiteralValueProvider.GetTextValue(SourceRange range) => TextValue; 21 | Symbol ILiteralValueProvider.GetTypeMarker(SourceRange range) => TypeMarker; 22 | object ILiteralValueProvider.GetValue(SourceRange range) => Value; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Core/Loyc.Syntax/LNodes/UninterpretedLiteral.cs: -------------------------------------------------------------------------------- 1 | namespace Loyc.Syntax 2 | { 3 | /// A simple implementation of which 4 | /// can also be turned into an LNode by calling 5 | /// . 6 | /// 7 | public struct UninterpretedLiteral : IUninterpretedLiteral, ILiteralValueProvider 8 | { 9 | public UninterpretedLiteral(UString textValue, Symbol typeMarker) 10 | { 11 | TextValue = textValue; 12 | TypeMarker = typeMarker; 13 | } 14 | public UString TextValue { get; } 15 | public Symbol TypeMarker { get; } 16 | 17 | UString ILiteralValueProvider.GetTextValue(SourceRange range) => TextValue; 18 | Symbol ILiteralValueProvider.GetTypeMarker(SourceRange range) => TypeMarker; 19 | object ILiteralValueProvider.GetValue(SourceRange range) => TextValue; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Core/Loyc.Syntax/Lexing/TriviaSaver.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Loyc.Collections; 6 | 7 | namespace Loyc.Syntax.Lexing 8 | { 9 | /// A lexer wrapper that saves whitespace tokens into a list (). 10 | /// 11 | /// This wrapper filters out all whitespace tokens (where is 12 | /// ) and saves them in a list. It is typically used with 13 | /// . 14 | /// 15 | public class TriviaSaver : LexerWrapper 16 | { 17 | /// Initializer. 18 | /// Lexer to wrap. 19 | /// In some languages, newlines are not considered 20 | /// whitespace but they still need to be saved in the trivia list. If the 21 | /// equals this value, the token is saved but NOT filtered out. 22 | public TriviaSaver(ILexer lexer, int newlineTypeInt = int.MinValue) : base(lexer) { _newlineTypeInt = newlineTypeInt; } 23 | 24 | int _newlineTypeInt; 25 | DList _trivia = new DList(); 26 | public IListAndListSource TriviaList { get { return _trivia; } } 27 | 28 | public override Maybe NextToken() 29 | { 30 | while ((_current = Lexer.NextToken()).HasValue) { 31 | var tok = _current.Value; 32 | if (tok.Value != WhitespaceTag.Value) { 33 | if (tok.TypeInt == _newlineTypeInt) 34 | TriviaList.Add(tok); 35 | break; 36 | } 37 | TriviaList.Add(tok); 38 | } 39 | return _current; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Core/Loyc.Syntax/Lexing/WhitespaceFilter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Loyc.Syntax.Lexing 7 | { 8 | /// Filters out tokens whose Value is . 9 | public class WhitespaceFilter : LexerWrapper 10 | where Token : IValue 11 | { 12 | public WhitespaceFilter(ILexer lexer) : base(lexer) { } 13 | 14 | public override Maybe NextToken() 15 | { 16 | do _current = Lexer.NextToken(); 17 | while (_current.HasValue && _current.Value.Value == WhitespaceTag.Value); 18 | return _current; 19 | } 20 | } 21 | 22 | /// Alias for WhitespaceFilter{Token} 23 | public class WhitespaceFilter : WhitespaceFilter 24 | { 25 | public WhitespaceFilter(ILexer lexer) : base(lexer) { } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Core/Loyc.Syntax/OpenSourceKey.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/Loyc.Syntax/OpenSourceKey.snk -------------------------------------------------------------------------------- /Core/Loyc.Syntax/Parsing/OperatorShape.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Loyc.Syntax 4 | { 5 | /// An enum of common operator formats. 6 | /// It is intentional that the absolute value of each OperatorShape 7 | /// (except Other) is the arity of (number of arguments to) that shape. 8 | public enum OperatorShape { Suffix = -1, Nullary = 0, Prefix = 1, Infix = 2, Ternary = 3, Other = 4 } 9 | } 10 | -------------------------------------------------------------------------------- /Core/Loyc.Syntax/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Loyc.Syntax")] 9 | [assembly: AssemblyDescription("Contains support classes for LLLPG, a parser for LES (Loyc Expression Syntax), the LNode (Loyc tree) class, and other code useful for parsers and lexers.")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("David Piepgrass")] 12 | [assembly: AssemblyProduct("Loyc.Syntax")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("3f8997a6-f8e4-4efe-a1fa-1a424cc742c7")] 23 | 24 | //[assembly: InternalsVisibleTo("LoycCore.Tests")] is not allowed in a signed assembly 25 | [assembly: InternalsVisibleTo("LoycCore.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100adec5c8e52098b94dc60b34ac0916d307eec23b2c285a0beeb7168174fc1f6a71dcae43c88904e2907a12f66861de8d8f130c4f7b57cff0aea92ed06b50d96c63cea2ee19ec5d35a2946ddef3f35f0fbd3ec3a358b46fd05c82837c49d91694c1926935dc83e2a28c1ff077e4d8a5f679f1edb1c8a692aa2913d753ea05f4fba")] 26 | -------------------------------------------------------------------------------- /Core/Loyc.Syntax/SourceFiles/SourceFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Diagnostics; 5 | using Loyc.MiniTest; 6 | using Loyc.Collections; 7 | 8 | namespace Loyc.Syntax 9 | { 10 | /// A default implementation of ISourceFile based on . 11 | public class SourceFile : IndexPositionMapper, ISourceFile 12 | where CharSource : ICharSource 13 | { 14 | new protected CharSource _source; 15 | 16 | public SourceFile(CharSource source, ILineColumnFile startingPos = null) : base(source, startingPos) { _source = source; } 17 | public SourceFile(CharSource source, string fileName) : base(source, fileName) { _source = source; } 18 | 19 | public CharSource Text 20 | { 21 | get { return _source; } 22 | } 23 | ICharSource ISourceFile.Text 24 | { 25 | get { return Text; } 26 | } 27 | } 28 | 29 | [Obsolete("Please use SourceFile instead.")] 30 | public class SourceFile : SourceFile 31 | { 32 | public SourceFile(ICharSource source, ILineColumnFile startingPos = null) : base(source, startingPos) { } 33 | public SourceFile(ICharSource source, string fileName) : base(source, fileName) { } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Core/Loyc.Utilities/Collections/AListExt.cs: -------------------------------------------------------------------------------- 1 | using Loyc.Collections; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Loyc.Collections 9 | { 10 | public static class AListExt 11 | { 12 | public static AListSumTracker SumTracker(this AListBase list) => SumTracker(list, n => n); 13 | public static AListSumTracker SumTracker(this AListBase list, Func selector) => new AListSumTracker(selector, list); 14 | public static AListSumTracker SumTracker(this AListBase list, Func selector) => new AListSumTracker(selector, list); 15 | public static AListStatisticTracker StatisticTracker(this AListBase list, 16 | Func selector, Func aggregator, TStatistic emptyResult) 17 | => new AListStatisticTracker(selector, aggregator, emptyResult, list); 18 | public static AListStatisticTracker StatisticTracker(this AListBase list, 19 | Func selector, Func aggregator, TStatistic emptyResult) 20 | => new AListStatisticTracker(selector, aggregator, emptyResult, list); 21 | public static AListStatisticTracker StatisticTracker(this AListBase list, Func selector) 22 | => new AListStatisticTracker(selector, list); 23 | public static AListStatisticTracker StatisticTracker(this AListBase list, Func selector) 24 | => new AListStatisticTracker(selector, list); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/Loyc.Utilities/Collections/CPTrie/Benchmark.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/Loyc.Utilities/Collections/CPTrie/Benchmark.xlsx -------------------------------------------------------------------------------- /Core/Loyc.Utilities/Collections/CPTrie/remember.txt: -------------------------------------------------------------------------------- 1 | - summarize first benchmark 2 | - correct '(I' -> '(a' 3 | - explain how splitting ocurrs 4 | - possibly update benchmark graph to be 'fairer' 5 | - 6 | 7 | - how did node with 2 children end up with large cell array? 8 | -------------------------------------------------------------------------------- /Core/Loyc.Utilities/GoInterface test project/GoInterface tests.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual Studio 2008 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GoInterface tests", "GoInterface tests.csproj", "{064ED9ED-335C-4EC4-834D-56AB9727F731}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {064ED9ED-335C-4EC4-834D-56AB9727F731}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 | {064ED9ED-335C-4EC4-834D-56AB9727F731}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {064ED9ED-335C-4EC4-834D-56AB9727F731}.Release|Any CPU.ActiveCfg = Release|Any CPU 15 | {064ED9ED-335C-4EC4-834D-56AB9727F731}.Release|Any CPU.Build.0 = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /Core/Loyc.Utilities/GoInterface test project/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using NUnit.Framework; 5 | 6 | namespace Loyc.Runtime 7 | { 8 | class Program 9 | { 10 | static void Main(string[] args) 11 | { 12 | // Note 1: benchmark should run first in order to measure the time it 13 | // takes to use GoInterface for the first time, which is the slowest. 14 | // Note 2: Release builds run a bit faster 15 | Console.WriteLine("Running GoInterface benchmark"); 16 | Console.WriteLine(); 17 | GoInterfaceBenchmark.DoBenchmark(); 18 | 19 | Console.WriteLine(); 20 | Console.WriteLine("Running GoInterface test suite"); 21 | Console.WriteLine(); 22 | RunTests.Run(new GoInterfaceTests()); 23 | 24 | Console.WriteLine(); 25 | Console.WriteLine("Press any key."); 26 | Console.ReadKey(true); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Core/Loyc.Utilities/GoInterface test project/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Core/Loyc.Utilities/GoInterface test project/nunit.framework.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/Loyc.Utilities/GoInterface test project/nunit.framework.dll -------------------------------------------------------------------------------- /Core/Loyc.Utilities/Loyc.Utilities.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netstandard2.0 4 | ..\Bin\$(Configuration)\ 5 | 1591, 1573, 0419 6 | true 7 | OpenSourceKey.snk 8 | false 9 | 10 | 11 | true 12 | ..\Bin\$(Configuration)\$(TargetFramework)\Loyc.Utilities.xml 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /Core/Loyc.Utilities/OpenSourceKey.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/Loyc.Utilities/OpenSourceKey.snk -------------------------------------------------------------------------------- /Core/Loyc.Utilities/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Loyc.Utilities")] 9 | [assembly: AssemblyDescription("Additional functionality following the theme \"things that should be built into the .NET framework, but aren't\". "+ 10 | "Stuff here is either (A) not important enough to be placed in Loyc.Essentials or (B) takes Loyc.Collections as a dependency.")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("David Piepgrass")] 13 | [assembly: AssemblyProduct("Loyc.Utilities")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("012ccf8b-ac29-4cdb-b72b-ea90d37eb0b8")] 24 | 25 | //[assembly: InternalsVisibleTo("LoycCore.Tests")] is not allowed in a signed assembly 26 | [assembly: InternalsVisibleTo("LoycCore.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100adec5c8e52098b94dc60b34ac0916d307eec23b2c285a0beeb7168174fc1f6a71dcae43c88904e2907a12f66861de8d8f130c4f7b57cff0aea92ed06b50d96c63cea2ee19ec5d35a2946ddef3f35f0fbd3ec3a358b46fd05c82837c49d91694c1926935dc83e2a28c1ff077e4d8a5f679f1edb1c8a692aa2913d753ea05f4fba")] 27 | -------------------------------------------------------------------------------- /Core/Loyc.Utilities/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Core/LoycCore.Benchmarks/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("LoycCore.Benchmarks")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("LoycCore.Benchmarks")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("0e34bc6b-c506-4a98-9350-8034c6daaa5d")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Core/LoycCore.Benchmarks/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Core/MiniTestRunner/Model/ContainerRowModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Reflection; 6 | using Loyc.Collections; 7 | using MiniTestRunner.TestDomain; 8 | using UpdateControls.Fields; 9 | 10 | namespace MiniTestRunner 11 | { 12 | [Serializable] 13 | class ContainerRowModel : RowModel 14 | { 15 | string _name; 16 | TestNodeType _type; 17 | IList _children; 18 | 19 | public ContainerRowModel(string name, TestNodeType type, List children) 20 | { 21 | _name = name; 22 | _type = type; 23 | _children = children; 24 | } 25 | 26 | public override string Name 27 | { 28 | get { return _name; } 29 | } 30 | 31 | IndependentS _Summary = new IndependentS("Summary", ""); 32 | public override string Summary 33 | { 34 | get { return _Summary.Value; } 35 | } 36 | public void SetSummary(string value) 37 | { 38 | _Summary.Value = value; 39 | } 40 | 41 | public override IList Children 42 | { 43 | get { return _children; } 44 | } 45 | public override TestNodeType Type 46 | { 47 | get { return _type; } 48 | } 49 | public override ITestTask Task 50 | { 51 | get { return null; } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Core/MiniTestRunner/Model/CrossDomainPropertyChangeHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Runtime.Remoting; 6 | using System.Runtime.Remoting.Lifetime; 7 | using MiniTestRunner.TestDomain; 8 | using System.Diagnostics; 9 | using System.Reflection; 10 | 11 | namespace MiniTestRunner 12 | { 13 | /// Allows a non-MarshalByRefObject to subscribe to PropertyChanged on 14 | /// an object in another AppDomain. The CLR may pretend to allow us to subscribe 15 | /// to the event directly, but when the event fires, it goes to a useless COPY 16 | /// of the subscriber that was silently created in the other AppDomain. 17 | public class CrossDomainPropertyChangeHelper : MarshalByRefObject, ISponsor, IDisposable 18 | { 19 | PropertyChangedDelegate _handler; 20 | 21 | /// Performs the logical operation "target.PropertyChanged += handler", 22 | /// where 'target' is located in another AppDomain, using this helper as an 23 | /// intermediary so that the subscription works correctly. 24 | public CrossDomainPropertyChangeHelper(IPropertyChanged target, PropertyChangedDelegate handler) 25 | { 26 | Debug.Assert(RemotingServices.IsTransparentProxy(target)); 27 | _handler = handler; 28 | target.PropertyChanged += Intermediary; 29 | 30 | // Honestly I don't know what I am doing. Tried to figure it out, failed. 31 | ((ILease)RemotingServices.GetLifetimeService(this)).Register(this); // register self as sponsor 32 | } 33 | 34 | public void Intermediary(object sender, string prop) 35 | { 36 | if (_handler != null) 37 | _handler(sender, prop); 38 | } 39 | public TimeSpan Renewal(ILease lease) 40 | { 41 | return _handler != null ? TimeSpan.FromSeconds(60) : TimeSpan.Zero; 42 | } 43 | public void Dispose() 44 | { 45 | _handler = null; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Core/MiniTestRunner/Model/IRowModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Loyc.Collections; 6 | using System.ComponentModel; 7 | using System.IO; 8 | using MiniTestRunner.TestDomain; 9 | 10 | namespace MiniTestRunner 11 | { 12 | /// See 13 | //public interface IRowModel : INotifyPropertyChanged 14 | //{ 15 | // string Name { get; } 16 | // TestNodeType Type { get; } 17 | // IList Children { get; } 18 | // int BasePriority { get; set; } 19 | // int InheritedPriority { get; set; } 20 | 21 | // ITestTask Task { get; } 22 | 23 | // // Properties may be copied from the ITestTask or ITaskEx 24 | // string Summary { get; } 25 | // TestStatus Status { get; } 26 | // DateTime LastRunAt { get; } 27 | // TimeSpan RunTime { get; } 28 | //} 29 | 30 | public enum TestNodeType 31 | { 32 | Assembly, TestFixture, TestSet, Test, Note 33 | } 34 | 35 | public enum TestStatus 36 | { 37 | None, 38 | NotRun, 39 | Success, 40 | SuccessWithMessage, 41 | Running, 42 | Inconclusive, 43 | Ignored, 44 | Error 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Core/MiniTestRunner/Model/NPCHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.ComponentModel; 6 | 7 | namespace MiniTestRunner 8 | { 9 | /// Helper class for implementing INotifyPropertyChanged 10 | [Serializable] 11 | public class NPCHelper : INotifyPropertyChanged 12 | { 13 | public event PropertyChangedEventHandler PropertyChanged; 14 | protected virtual void Changed(string prop) 15 | { 16 | if (PropertyChanged != null) 17 | PropertyChanged(this, new PropertyChangedEventArgs(prop)); 18 | } 19 | protected bool Set(ref T var, T value, string propName) 20 | { 21 | if (var == null ? value != null : !var.Equals(value)) { 22 | var = value; 23 | Changed(propName); 24 | return true; 25 | } 26 | return false; 27 | } 28 | protected bool Set(ref int var, int value, string propName) 29 | { 30 | if (var != value) { 31 | var = value; 32 | Changed(propName); 33 | return true; 34 | } 35 | return false; 36 | } 37 | protected bool Set(ref bool var, bool value, string propName) 38 | { 39 | if (var != value) { 40 | var = value; 41 | Changed(propName); 42 | return true; 43 | } 44 | return false; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Core/MiniTestRunner/Model/ResultSet.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using UpdateControls.Collections; 6 | 7 | namespace MiniTestRunner.Model 8 | { 9 | public class ResultSet 10 | { 11 | IndependentList _roots = new IndependentList(); 12 | public IList Assemblies 13 | { 14 | get { return _roots; } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Core/MiniTestRunner/OpenSourceKey.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/MiniTestRunner/OpenSourceKey.snk -------------------------------------------------------------------------------- /Core/MiniTestRunner/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("MiniTestRunner")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("MiniTestRunner")] 13 | [assembly: AssemblyCopyright("Copyright © 2011")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("982ae505-5edb-4db5-aee7-5c907bcd69af")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /Core/MiniTestRunner/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.18444 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace MiniTestRunner.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/MiniTestRunner/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Core/MiniTestRunner/Resources/Assembly.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/MiniTestRunner/Resources/Assembly.png -------------------------------------------------------------------------------- /Core/MiniTestRunner/Resources/Benchmark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/MiniTestRunner/Resources/Benchmark.png -------------------------------------------------------------------------------- /Core/MiniTestRunner/Resources/Class.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/MiniTestRunner/Resources/Class.png -------------------------------------------------------------------------------- /Core/MiniTestRunner/Resources/HighPriority.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/MiniTestRunner/Resources/HighPriority.png -------------------------------------------------------------------------------- /Core/MiniTestRunner/Resources/LowPriority.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/MiniTestRunner/Resources/LowPriority.png -------------------------------------------------------------------------------- /Core/MiniTestRunner/Resources/OpenProject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/MiniTestRunner/Resources/OpenProject.png -------------------------------------------------------------------------------- /Core/MiniTestRunner/Resources/ResultSet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/MiniTestRunner/Resources/ResultSet.png -------------------------------------------------------------------------------- /Core/MiniTestRunner/Resources/RunIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/MiniTestRunner/Resources/RunIcon.png -------------------------------------------------------------------------------- /Core/MiniTestRunner/Resources/SplitHorizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/MiniTestRunner/Resources/SplitHorizontal.png -------------------------------------------------------------------------------- /Core/MiniTestRunner/Resources/StatusError.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/MiniTestRunner/Resources/StatusError.png -------------------------------------------------------------------------------- /Core/MiniTestRunner/Resources/StatusFlag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/MiniTestRunner/Resources/StatusFlag.png -------------------------------------------------------------------------------- /Core/MiniTestRunner/Resources/StatusIgnored.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/MiniTestRunner/Resources/StatusIgnored.png -------------------------------------------------------------------------------- /Core/MiniTestRunner/Resources/StatusMessage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/MiniTestRunner/Resources/StatusMessage.png -------------------------------------------------------------------------------- /Core/MiniTestRunner/Resources/StatusNote.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/MiniTestRunner/Resources/StatusNote.png -------------------------------------------------------------------------------- /Core/MiniTestRunner/Resources/StatusRunning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/MiniTestRunner/Resources/StatusRunning.png -------------------------------------------------------------------------------- /Core/MiniTestRunner/Resources/StatusSuccess.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/MiniTestRunner/Resources/StatusSuccess.png -------------------------------------------------------------------------------- /Core/MiniTestRunner/Resources/StatusUnknown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/MiniTestRunner/Resources/StatusUnknown.png -------------------------------------------------------------------------------- /Core/MiniTestRunner/Resources/StatusWarning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/MiniTestRunner/Resources/StatusWarning.png -------------------------------------------------------------------------------- /Core/MiniTestRunner/Resources/StopIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/MiniTestRunner/Resources/StopIcon.png -------------------------------------------------------------------------------- /Core/MiniTestRunner/Resources/Test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/MiniTestRunner/Resources/Test.png -------------------------------------------------------------------------------- /Core/MiniTestRunner/Resources/TestSet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/MiniTestRunner/Resources/TestSet.png -------------------------------------------------------------------------------- /Core/MiniTestRunner/Resources/TreeOnly.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/MiniTestRunner/Resources/TreeOnly.png -------------------------------------------------------------------------------- /Core/MiniTestRunner/Resources/WordWrap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/MiniTestRunner/Resources/WordWrap.png -------------------------------------------------------------------------------- /Core/MiniTestRunner/TestDomain/IPropertyChanged.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace MiniTestRunner.TestDomain 7 | { 8 | /// Same as INotifyPropertyChanged, except that it can be used across 9 | /// AppDomains because it does not use the PropertyChangedEventArgs argument 10 | /// (which is not serializable or marshalable). 11 | public interface IPropertyChanged 12 | { 13 | event PropertyChangedDelegate PropertyChanged; 14 | } 15 | 16 | public delegate void PropertyChangedDelegate(object sender, string propertyName); 17 | 18 | /// Helper base class for implementing . 19 | public class PropertyChangedHelper : MarshalByRefObject, IPropertyChanged 20 | { 21 | public event PropertyChangedDelegate PropertyChanged; 22 | 23 | protected virtual void Changed(string prop) 24 | { 25 | if (PropertyChanged != null) 26 | PropertyChanged(this, prop); 27 | } 28 | protected void Set(ref T var, T value, string propName) 29 | { 30 | if (var == null ? value != null : !var.Equals(value)) { 31 | var = value; 32 | Changed(propName); 33 | } 34 | } 35 | protected void Set(ref int var, int value, string propName) 36 | { 37 | if (var != value) { 38 | var = value; 39 | Changed(propName); 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Core/MiniTestRunner/TestDomain/ITask.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | 7 | namespace MiniTestRunner.TestDomain 8 | { 9 | /// Task interface needed by TaskRunner and the GUI 10 | public interface ITestTask : IPropertyChanged, ITask 11 | { 12 | new int Priority { get; set; } // add setter (ITask has only a getter) 13 | TestStatus Status { get; } 14 | DateTime LastRunAt { get; } 15 | TimeSpan RunTime { get; } 16 | } 17 | 18 | /// Task interface needed by TaskRowModel 19 | public interface ITaskEx : ITestTask 20 | { 21 | Stream OutputStream { get; set; } 22 | IList Children { get; } 23 | string Summary { get; } 24 | string AssemblyPath { get; } 25 | AppDomain Domain { get; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Core/MiniTestRunner/Utils/ViewModelOf.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace MiniTestRunner.ViewModel 7 | { 8 | public class ViewModelOf 9 | { 10 | protected T _model; 11 | 12 | public ViewModelOf(T model) 13 | { 14 | _model = model; 15 | } 16 | public T Model 17 | { 18 | get { return _model; } 19 | } 20 | public override bool Equals(object obj) 21 | { 22 | var vm = obj as ViewModelOf; 23 | return vm != null && vm._model.Equals(_model); 24 | } 25 | public override int GetHashCode() 26 | { 27 | return _model.GetHashCode(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/MiniTestRunner/Utils/WeakReference.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace MiniTestRunner 7 | { 8 | // Adds strong typing to WeakReference.Target using generics. Also, 9 | // the Create factory method is used in place of a constructor 10 | // to handle the case where target is null, but we want the 11 | // reference to still appear to be alive. 12 | public class WeakReference : WeakReference where T : class 13 | { 14 | public static WeakReference Create(T target) 15 | { 16 | if (target == null) 17 | return WeakNullReference.Singleton; 18 | 19 | return new WeakReference(target); 20 | } 21 | 22 | protected WeakReference(T target) 23 | : base(target, false) { } 24 | 25 | public new T Target 26 | { 27 | get { return (T)base.Target; } 28 | } 29 | } 30 | 31 | // Provides a weak reference to a null target object, which, unlike 32 | // other weak references, is always considered to be alive. This 33 | // facilitates handling null dictionary values, which are perfectly 34 | // legal. 35 | public class WeakNullReference : WeakReference where T : class 36 | { 37 | public static readonly WeakNullReference Singleton = new WeakNullReference(); 38 | 39 | private WeakNullReference() : base(null) { } 40 | 41 | public override bool IsAlive 42 | { 43 | get { return true; } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Core/MiniTestRunner/ViewModel/DisplaySettingsVM.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace MiniTestRunner.ViewModel 7 | { 8 | class DisplaySettingsVM : NPCHelper 9 | { 10 | public string Filter { get; set; } 11 | public bool HideSuccess { get; set; } 12 | public bool HideIgnored { get; set; } 13 | 14 | internal bool IsFilteredOut(RowModel m) 15 | { 16 | throw new NotImplementedException(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Core/MiniTestRunner/ViewModel/TreeVM.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using UpdateControls.Collections; 6 | using UpdateControls.Fields; 7 | using MiniTestRunner.Model; 8 | using Loyc.Collections; 9 | 10 | namespace MiniTestRunner.ViewModel 11 | { 12 | public class ProjectVM : ViewModelOf 13 | { 14 | public ProjectVM(ProjectModel model, FilterVM filter) : base(model) 15 | { 16 | _filter = filter ?? new FilterVM(); 17 | _roots = new DependentList(() => Filter.ApplyTo(_model.Roots).Select(m => new RowVM(m, this, null))); 18 | _roots.DependentSentry.Invalidated += () => FireChildrenInvalidated(null); 19 | } 20 | 21 | readonly FilterVM _filter; 22 | public FilterVM Filter { get { return _filter; } } 23 | 24 | DependentList _roots; 25 | public DependentList Roots { get { return _roots; } } 26 | 27 | internal void FireRowInvalidated(RowVM row) { var p = RowInvalidated; if (p != null) p(row); } 28 | internal void FireChildrenInvalidated(RowVM row) { var p = ChildrenInvalidated; if (p != null) p(row); } 29 | public event Action RowInvalidated; 30 | public event Action ChildrenInvalidated; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Core/MiniTestRunner/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Core/Readme.md: -------------------------------------------------------------------------------- 1 | README 2 | ====== 3 | 4 | The Loyc Core project is a set of general-purpose .NET libraries. LoycCore is especially focused on collections - classes, interfaces, adapters, and extension methods - but also has code in other areas, most notably parsing and syntax trees. 5 | 6 | Contributors are welcome: more unit tests, code reviews, and new features are desired, anything relatively small (under about 3000 lines of code) that fits the theme "things that should have been built into the .NET framework, but aren't". 7 | 8 | Please visit http://core.loyc.net for documentation. 9 | 10 | **NOTE**: Development occurs primarily in the [Enhanced C# repository](https://github.com/qwertie/ecsharp), which contains the LoycCore repo as a "git subtree". However, `git subtree push` mysteriously stopped working which means that synchronization with this repo has become a manual process. As a result I would ask you **not to use that repo anymore**. We'll just do everything in ecsharp. 11 | 12 | Dependency tree 13 | --------------- 14 | 15 | Low-level libraries on top: 16 | 17 | Loyc.Interfaces 18 | ^ 19 | | 20 | Loyc.Essentials 21 | ^ ^ 22 | | | 23 | | +----------------+ 24 | | | 25 | Loyc.Collections Loyc.Math 26 | ^ ^ 27 | | | 28 | Loyc.Syntax | 29 | ^ | 30 | | | 31 | +---------+----------+ 32 | | 33 | Loyc.Utilities 34 | 35 | Links 36 | ----- 37 | 38 | - [Home Page](http://core.loyc.net) 39 | - [Reference Documentation](http://ecsharp.net/doc/code/) 40 | - [Source code](http://github.com/qwertie/LoycCore) 41 | - [Blog](http://loyc.net/blog) 42 | -------------------------------------------------------------------------------- /Core/Tests/Collections/InternalDArrayTests.cs: -------------------------------------------------------------------------------- 1 | using Loyc.Collections; 2 | using Loyc.MiniTest; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | namespace Loyc.Collections.Tests 9 | { 10 | [TestFixture] 11 | public class InternalDArrayTests 12 | { 13 | Random _r; 14 | public InternalDArrayTests(int seed) 15 | { 16 | _r = new Random(seed); 17 | } 18 | 19 | [Test] 20 | public void FuzzTest() 21 | { 22 | for (int trial = 0; trial < 100; trial++) { 23 | var dict = new Dictionary(); 24 | var list = InternalDArray.Empty; 25 | for (int i = 0; i < 20; i++) { 26 | int index = _r.Next(-20, 20); 27 | dict[index] = (float)i; 28 | list[index] = (float)i; 29 | } 30 | for (int index = -20; index < 20; index++) { 31 | dict.TryGetValue(index, out float expected); 32 | Assert.AreEqual(expected, list[index, 0]); 33 | } 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Core/Tests/Collections/TypeDictionaryWithBaseTypeLookupsTests.cs: -------------------------------------------------------------------------------- 1 | using Loyc.MiniTest; 2 | using System; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | 8 | namespace Loyc.Collections.Tests 9 | { 10 | [TestFixture] 11 | public class TypeDictionaryWithBaseTypeLookupsTests 12 | { 13 | [Test] 14 | public void BasicTests() 15 | { 16 | var dict = new TypeDictionaryWithBaseTypeLookups(); 17 | dict[typeof(bool)] = "bool"; 18 | dict[typeof(string)] = "string"; 19 | dict[typeof(ValueType)] = "ValueType"; 20 | dict[typeof(IEnumerable)] = "IEnumerable"; 21 | 22 | string value; 23 | Assert.IsTrue(dict.ContainsKey(typeof(string))); 24 | Assert.IsTrue(dict.ContainsKey(typeof(IEnumerable))); 25 | Assert.IsTrue(dict.ContainsKey(typeof(bool))); 26 | Assert.IsFalse(dict.ContainsKey(typeof(int))); 27 | Assert.IsFalse(dict.ContainsKey(typeof(IList))); 28 | Assert.IsTrue(dict.TryGetValue(typeof(bool), out value)); 29 | Assert.AreEqual("bool", value); 30 | Assert.IsTrue(dict.TryGetValue(typeof(int), out value)); 31 | Assert.AreEqual("ValueType", value); 32 | Assert.IsTrue(dict.TryGetValue(typeof(IList), out value)); 33 | Assert.AreEqual("IEnumerable", value); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Core/Tests/Essentials/BaisTests.cs: -------------------------------------------------------------------------------- 1 | using Loyc.Collections.Impl; 2 | using Loyc.MiniTest; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Loyc.Essentials.Tests 10 | { 11 | [TestFixture] 12 | public class BaisTests : TestHelpers 13 | { 14 | [Test] 15 | public void BasicTest() 16 | { 17 | var arr = new byte[] { 67, 97, 116, 128, 10, 69, 255, 65, 66, 67, 68 }; 18 | var str = "Cat\b`@iE?tEB!CD"; 19 | var str2 = ByteArrayInString.Convert(arr); 20 | var arr2 = ByteArrayInString.Convert(str); 21 | Assert.AreEqual(str, str2); 22 | ExpectList(arr, arr2); 23 | } 24 | 25 | Random _r = new Random(); 26 | 27 | [Test] 28 | public void RandomTest() 29 | { 30 | for (int len = 0; len < 100; len++) { 31 | byte[] bytes = new byte[len]; 32 | _r.NextBytes(bytes); 33 | string asStr = ByteArrayInString.Convert(bytes); 34 | byte[] result = ByteArrayInString.Convert(asStr).ToArray(); 35 | ExpectList(result, bytes); 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Core/Tests/Essentials/DictionaryWrapperTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Loyc.Collections; 7 | using Loyc.Collections.Impl; 8 | using Loyc.Collections.Tests; 9 | 10 | namespace Loyc.Essentials.Tests 11 | { 12 | public class DictionaryWrapperForTesting : DictionaryWrapper>, 13 | IAddRange>, ICloneable> 14 | { 15 | public DictionaryWrapperForTesting() : base(new Dictionary()) { } 16 | public DictionaryWrapperForTesting(Dictionary obj) : base(obj) { } 17 | 18 | public void AddRange(IEnumerable> e) => DictionaryExt.AddRange(_obj, e); 19 | 20 | public void AddRange(IReadOnlyCollection> s) => DictionaryExt.AddRange(_obj, s); 21 | 22 | public DictionaryWrapperForTesting Clone() => new DictionaryWrapperForTesting(new Dictionary(_obj)); 23 | } 24 | 25 | class DictionaryWrapperTests : DictionaryTests> 26 | { 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Core/Tests/Essentials/ExtensionsTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Loyc.MiniTest; 6 | 7 | namespace Loyc.Essentials.Tests 8 | { 9 | [TestFixture] 10 | public class StringExtTests : Assert 11 | { 12 | // TODO 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Core/Tests/Essentials/ListWrapperTests.cs: -------------------------------------------------------------------------------- 1 | using Loyc.Collections; 2 | using Loyc.Collections.Impl; 3 | using Loyc.Collections.Tests; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace Loyc.Essentials.Tests 11 | { 12 | public class ListWrapperForTesting : ListWrapper>, 13 | IAddRange, ICloneable> 14 | { 15 | public ListWrapperForTesting() : base(new List()) { } 16 | public ListWrapperForTesting(List obj) : base(obj) { } 17 | 18 | public void AddRange(IEnumerable e) => ListExt.AddRange(_obj, e); 19 | 20 | public void AddRange(IReadOnlyCollection s) => ListExt.AddRange(_obj, s); 21 | 22 | public ListWrapperForTesting Clone() => new ListWrapperForTesting(new List(_obj)); 23 | } 24 | 25 | public class ListWrapperTests : ListTests> 26 | { 27 | public ListWrapperTests(int randomSeed) 28 | : base(true, size => new ListWrapperForTesting().With(l => l.Resize(size)), randomSeed) { } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Core/Tests/Essentials/LocalizeTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Loyc.MiniTest; 6 | 7 | namespace Loyc.Essentials.Tests 8 | { 9 | [TestFixture] 10 | public class LocalizeTests 11 | { 12 | [Test] 13 | public void DefaultFormatter() 14 | { 15 | //Assert.AreEqual(Localize.EliminateNamedArgs( 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Core/Tests/Essentials/PrintHelpersTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Loyc.Math; 6 | using Loyc.MiniTest; 7 | using Loyc.Syntax; 8 | 9 | namespace Loyc.Essentials.Tests 10 | { 11 | [TestFixture] 12 | public class PrintHelpersTests : Assert 13 | { 14 | [Test] 15 | public void IntegerToStringTests() 16 | { 17 | AreEqual(PrintHelpers.IntegerToString(0, "", 10, 3, '_'), "0"); 18 | AreEqual(PrintHelpers.IntegerToString(123, "0d", 10, 3, '_'), "0d123"); 19 | AreEqual(PrintHelpers.IntegerToString(0x123, "0x", 16, 3, '_'), "0x123"); 20 | AreEqual(PrintHelpers.IntegerToString(126uL, "0b", 2, 4, '_'), "0b111_1110"); 21 | AreEqual(PrintHelpers.IntegerToString(9876, "", 10, 3, ','), "9,876"); 22 | AreEqual(PrintHelpers.IntegerToString(-1234567, "0d", 10, 3, '\''), "-0d1'234'567"); 23 | AreEqual(PrintHelpers.IntegerToString(-1234567, "0d", 10, 0, '\''), "-0d1234567"); 24 | AreEqual(PrintHelpers.IntegerToString(-0x1234567890ABCD, "0x", 16, 4, '_'), "-0x12_3456_7890_ABCD"); 25 | AreEqual(PrintHelpers.IntegerToString(0xFEEDFEEDFEEDFEEDuL, "0x", 16, 4, '_'), "0xFEED_FEED_FEED_FEED"); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Core/Tests/Essentials/ThreadExTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Loyc.MiniTest; 6 | using System.Threading; 7 | using Loyc.Threading; 8 | 9 | namespace Loyc.Essentials.Tests 10 | { 11 | [TestFixture] 12 | public class ThreadExTests 13 | { 14 | [Test] 15 | public void BasicChecks() 16 | { 17 | ThreadLocalVariable threadVar = new ThreadLocalVariable(123); 18 | Thread parent = Thread.CurrentThread; 19 | bool eventOccurred = false; 20 | bool valueOk = true, eventOk = true; 21 | bool stop = false; 22 | bool started = false; 23 | 24 | ThreadEx t = new ThreadEx(delegate(object o) 25 | { 26 | started = true; 27 | try 28 | { 29 | if ((int)o != 123 || threadVar.Value != 123) 30 | valueOk = false; 31 | } 32 | catch 33 | { 34 | valueOk = false; 35 | } 36 | while (!stop) 37 | GC.KeepAlive(""); // Waste time 38 | started = false; 39 | }); 40 | 41 | EventHandler eh = null; 42 | ThreadEx.ThreadStarting += (eh = delegate(object o, ThreadStartEventArgs e) 43 | { 44 | eventOccurred = true; 45 | if (e.ChildThread != t || e.ParentThread != parent) 46 | eventOk = false; 47 | ThreadEx.ThreadStarting -= eh; 48 | }); 49 | 50 | Assert.IsFalse(t.IsAlive); 51 | Assert.AreEqual(System.Threading.ThreadState.Unstarted, t.ThreadState); 52 | t.Start(123); 53 | Assert.IsTrue(t.IsAlive); 54 | Assert.IsTrue(eventOccurred); 55 | Assert.IsTrue(eventOk); 56 | while (!started) 57 | ThreadEx.Sleep(0); 58 | Assert.AreEqual(System.Threading.ThreadState.Running, t.ThreadState); 59 | stop = true; 60 | Assert.IsTrue(t.Join(5000)); 61 | Assert.IsTrue(valueOk); 62 | Assert.IsFalse(started); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Core/Tests/LoycCore.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netstandard2.0 4 | ..\Bin\$(Configuration)\ 5 | Exe 6 | 1591, 1573, 0419 7 | true 8 | OpenSourceKey.snk 9 | false 10 | 11 | 12 | true 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | LexerSourceTest.ecs 23 | True 24 | True 25 | 26 | 27 | LeMP 28 | LexerSourceTest.out.cs 29 | 30 | 31 | ParserSourceTest.ecs 32 | True 33 | True 34 | 35 | 36 | LeMP 37 | ParserSourceTest.out.cs 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Core/Tests/OpenSourceKey.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Core/Tests/OpenSourceKey.snk -------------------------------------------------------------------------------- /Core/Tests/Syntax/MiscTests.cs: -------------------------------------------------------------------------------- 1 | using Loyc.MiniTest; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Loyc.Syntax 9 | { 10 | using S = CodeSymbols; 11 | 12 | // Mostly LNode tests 13 | [TestFixture] 14 | public class MiscTests 15 | { 16 | [Test] 17 | public void IsTrivia() 18 | { 19 | Assert.IsTrue(S.IsTriviaSymbol(S.TriviaAppendStatement)); 20 | Assert.IsTrue(S.IsTriviaSymbol(S.TriviaSLComment)); 21 | Assert.IsTrue(S.IsTriviaSymbol((Symbol)"#trivia_foo")); 22 | Assert.IsFalse(S.IsTriviaSymbol((Symbol)"#triviaFoo")); 23 | Assert.IsTrue(S.IsTriviaSymbol((Symbol)"%Foo")); 24 | Assert.IsFalse(S.IsTriviaSymbol((Symbol)"'Foo")); 25 | Assert.IsTrue(S.IsTriviaSymbol((Symbol)"%")); 26 | Assert.IsFalse(S.IsTriviaSymbol(GSymbol.Empty)); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Doc/Please see docs on ecsharp.net: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Doc/Please see docs on ecsharp.net -------------------------------------------------------------------------------- /Doc/VeryOldDocs/thanks.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Loyc: Thanks 11 | 12 | 13 | 14 | 15 |

Thanks

16 |
17 | There were several sources of inspiration for the present design:
18 | 25 |
26 |
27 | 28 | 29 |
"Loyc is the Bazaar-cathedral of programming languages. Or is 30 | it a Bizarre Cathedral?" - Eric 31 | S. Raymond (no, he didn't really say that)
32 | 33 | 34 |
35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /Lib/ICSharpCode.TextEditor.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Lib/ICSharpCode.TextEditor.dll -------------------------------------------------------------------------------- /Lib/protobuf-net.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Lib/protobuf-net.dll -------------------------------------------------------------------------------- /Lib/protobuf-net.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Lib/protobuf-net.pdb -------------------------------------------------------------------------------- /Main/Ecs/OpenSourceKey.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Main/Ecs/OpenSourceKey.snk -------------------------------------------------------------------------------- /Main/Ecs/Parser/EcsLiteralHandlers.cs: -------------------------------------------------------------------------------- 1 | using Loyc.Syntax; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace Loyc.Ecs.Parser 8 | { 9 | public class EcsLiteralHandlers : StandardLiteralHandlers 10 | { 11 | private static EcsLiteralHandlers _value = null; 12 | public new static EcsLiteralHandlers Value => _value = _value ?? new EcsLiteralHandlers(); 13 | 14 | public EcsLiteralHandlers() 15 | { 16 | // TODO: This isn't the right way to parse decimal, but I'm in a hurry 17 | AddParser(true, (Symbol)"_m", (s, tm) => 18 | ParseDouble(s, out double n) ? OK((decimal)n) : SyntaxError(s, tm)); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Main/Ecs/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Enhanced C# parser & printer")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Loyc.Ecs")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("da166302-7509-497d-ae30-668baa88e9e0")] 23 | -------------------------------------------------------------------------------- /Main/Ecs/Tests/EcsValidatorTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Loyc.MiniTest; 6 | 7 | namespace Loyc.Ecs.Tests 8 | { 9 | // TODO: more tests 10 | public class EcsValidatorTests : Assert 11 | { 12 | [Test] 13 | public void SanitizeIdentifierTests() 14 | { 15 | AreEqual("I_aposd", EcsValidators.SanitizeIdentifier("I'd")); 16 | AreEqual("_123", EcsValidators.SanitizeIdentifier("123")); 17 | AreEqual("_plus5", EcsValidators.SanitizeIdentifier("+5" )); 18 | AreEqual("__empty__",EcsValidators.SanitizeIdentifier("" )); 19 | AreEqual("_lt_gt", EcsValidators.SanitizeIdentifier("<>")); 20 | AreEqual("_apos_period", EcsValidators.SanitizeIdentifier("'.")); 21 | } 22 | 23 | [Test] 24 | public void IsPlainCsIdentifierTests() 25 | { 26 | IsTrue(EcsValidators.IsPlainCsIdentifier("x")); 27 | IsTrue(EcsValidators.IsPlainCsIdentifier("aAzZ_")); 28 | IsTrue(EcsValidators.IsPlainCsIdentifier("_19aAzZ")); 29 | IsFalse(EcsValidators.IsPlainCsIdentifier("19aAzZ")); 30 | IsFalse(EcsValidators.IsPlainCsIdentifier("_<>_")); 31 | IsFalse(EcsValidators.IsPlainCsIdentifier("I'd")); 32 | IsFalse(EcsValidators.IsPlainCsIdentifier("C#")); 33 | IsFalse(EcsValidators.IsPlainCsIdentifier("#5")); 34 | IsFalse(EcsValidators.IsPlainCsIdentifier("")); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Main/Ecs/Tests/ToDoTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Loyc.MiniTest; 5 | using S = Loyc.Syntax.CodeSymbols; 6 | 7 | namespace Loyc.Ecs.Tests 8 | { 9 | partial class EcsPrinterAndParserTests 10 | { 11 | /* Not planning to implement 'if' clauses, for now 12 | [Test] 13 | public void BraceInIfClause() 14 | { 15 | // A braced block is not allowed inside an "if" clause. However we 16 | // don't have a good way to prevent it. 17 | var stmt = Attr(F.Call(S.If, F.Call(S.Eq, a, F.Braces(b))), 18 | F.Call(S.Namespace, Foo, F._Missing)); 19 | Stmt("namespace Foo if a == @`{}`(b);", stmt); 20 | stmt = Attr(F.Call(S.If, F.Call(S.Eq, a, StmtStyle(F.List(b)))), 21 | F.Call(S.Class, Foo)); 22 | Stmt("class Foo if a == #(b);", stmt); 23 | } 24 | */ 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/.gitignore: -------------------------------------------------------------------------------- 1 | *.user 2 | *.suo 3 | _ReSharper.*/ 4 | bin/ 5 | obj/ 6 | TestResults/ 7 | *.vsp 8 | config.backup 9 | ICSharpCode.TextEditor.userprefs 10 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/ICSharpCode.TextEditor.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor", "Project\ICSharpCode.TextEditor.csproj", "{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}" 5 | EndProject 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", "NuGet", "{473FFBA4-5301-4199-968C-7CC084C464E3}" 7 | ProjectSection(SolutionItems) = preProject 8 | Project\ICSharpCode.TextEditor.dll.nuspec = Project\ICSharpCode.TextEditor.dll.nuspec 9 | EndProjectSection 10 | EndProject 11 | Global 12 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 13 | Debug|Any CPU = Debug|Any CPU 14 | Release|Any CPU = Release|Any CPU 15 | EndGlobalSection 16 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 17 | {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 18 | {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Debug|Any CPU.Build.0 = Debug|Any CPU 19 | {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|Any CPU.ActiveCfg = Release|Any CPU 20 | {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|Any CPU.Build.0 = Release|Any CPU 21 | EndGlobalSection 22 | GlobalSection(NestedProjects) = preSolution 23 | EndGlobalSection 24 | GlobalSection(SolutionProperties) = preSolution 25 | HideSolutionNode = FALSE 26 | EndGlobalSection 27 | EndGlobal 28 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Configuration/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | 5 | [assembly: CLSCompliant(true)] 6 | [assembly: StringFreezing()] 7 | 8 | [assembly: AssemblyTitle("ICSharpCode.TextEditor")] 9 | [assembly: AssemblyDescription("A .NET text editor control")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyTrademark("")] 12 | [assembly: AssemblyCulture("")] 13 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Configuration/GlobalAssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////////////////// 2 | ///////////////////////////////////////////////////////////////////////////////////////////// 3 | // // 4 | // DO NOT EDIT GlobalAssemblyInfo.cs, it is recreated using AssemblyInfo.template whenever // 5 | // StartUp is compiled. // 6 | // // 7 | ///////////////////////////////////////////////////////////////////////////////////////////// 8 | ///////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | using System.Resources; 11 | using System.Reflection; 12 | 13 | [assembly: System.Runtime.InteropServices.ComVisible(false)] 14 | [assembly: AssemblyCompany("ic#code")] 15 | [assembly: AssemblyProduct("SharpDevelop")] 16 | [assembly: AssemblyCopyright("2000-2010 AlphaSierraPapa")] 17 | [assembly: AssemblyVersion(RevisionClass.FullVersion)] 18 | [assembly: NeutralResourcesLanguage("en-US")] 19 | 20 | internal static class RevisionClass 21 | { 22 | public const string Major = "4"; 23 | public const string Minor = "0"; 24 | public const string Build = "2"; 25 | public const string Revision = "6466"; 26 | 27 | public const string MainVersion = Major + "." + Minor; 28 | public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision; 29 | } 30 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/ICSharpCode.TextEditor.dll.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ICSharpCode.TextEditor.dll 5 | 4.0.2.6466 6 | ic#code 7 | ic#code 8 | http://opensource.org/licenses/lgpl-2.1.php 9 | http://www.codeproject.com/Articles/30936/Using-ICSharpCode-TextEditor 10 | http://community.sharpdevelop.net/blogs/mattward/SharpDevelop.png 11 | false 12 | A WinForms control for rendering and editing text 13 | version for mypad-winforms-texteditor. 14 | Earlier the editor was a part of SharpDevelop 3.5 - .\SharpDevelop\src\Libraries\ICSharpCode.TextEditor\Project 15 | Last known location - https://github.com/ArsenShnurkov/ICSharpCode.TextEditor 16 | 17 | 2000-2010 AlphaSierraPapa, 2015 - Arsen.Shnurkov@gmail.com 18 | winforms mono 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/ICSharpCode.TextEditor.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor", "ICSharpCode.TextEditor.csproj", "{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 | {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|Any CPU.ActiveCfg = Release|Any CPU 15 | {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|Any CPU.Build.0 = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(MonoDevelopProperties) = preSolution 18 | StartupItem = ICSharpCode.TextEditor.csproj 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Resources/ASPX.xshd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | <% 7 | %> 8 | 9 | 10 | 11 | 12 | 13 | // 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Resources/BAT-Mode.xshd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Resources/ICSharpCode.TextEditor.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Main/ICSharpCode.TextEditor/Project/Resources/ICSharpCode.TextEditor.snk -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Resources/Patch-Mode.xshd: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | ~!%^*()-+=|\#/{}[]:;"'<> , .? 9 | 10 | 11 | Index: 12 | 13 | 14 | == 15 | 16 | 17 | --- 18 | 19 | 20 | +++ 21 | 22 | 23 | @@ 24 | 25 | 26 | - 27 | 28 | 29 | + 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Resources/RightArrow.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Main/ICSharpCode.TextEditor/Project/Resources/RightArrow.cur -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Resources/TextEditorControl.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Main/ICSharpCode.TextEditor/Project/Resources/TextEditorControl.bmp -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Actions/ClipBoardActions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ICSharpCode.TextEditor.Actions 4 | { 5 | public class Cut : AbstractEditAction 6 | { 7 | public override void Execute(TextArea textArea) 8 | { 9 | if (textArea.Document.ReadOnly) { 10 | return; 11 | } 12 | textArea.ClipboardHandler.Cut(null, null); 13 | } 14 | } 15 | 16 | public class Copy : AbstractEditAction 17 | { 18 | public override void Execute(TextArea textArea) 19 | { 20 | textArea.AutoClearSelection = false; 21 | textArea.ClipboardHandler.Copy(null, null); 22 | } 23 | } 24 | 25 | public class Paste : AbstractEditAction 26 | { 27 | public override void Execute(TextArea textArea) 28 | { 29 | if (textArea.Document.ReadOnly) { 30 | return; 31 | } 32 | textArea.ClipboardHandler.Paste(null, null); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Actions/IEditAction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace ICSharpCode.TextEditor.Actions 5 | { 6 | /// 7 | /// To define a new key for the textarea, you must write a class which 8 | /// implements this interface. 9 | /// 10 | public interface IEditAction 11 | { 12 | /// 13 | /// An array of keys on which this edit action occurs. 14 | /// 15 | Keys[] Keys { 16 | get; 17 | set; 18 | } 19 | 20 | /// 21 | /// When the key which is defined per XML is pressed, this method will be launched. 22 | /// 23 | void Execute(TextArea textArea); 24 | } 25 | 26 | /// 27 | /// To define a new key for the textarea, you must write a class which 28 | /// implements this interface. 29 | /// 30 | public abstract class AbstractEditAction : IEditAction 31 | { 32 | Keys[] keys = null; 33 | 34 | /// 35 | /// An array of keys on which this edit action occurs. 36 | /// 37 | public Keys[] Keys { 38 | get { 39 | return keys; 40 | } 41 | set { 42 | keys = value; 43 | } 44 | } 45 | 46 | /// 47 | /// When the key which is defined per XML is pressed, this method will be launched. 48 | /// 49 | public abstract void Execute(TextArea textArea); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Document/AbstractSegment.cs: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | // 5 | // $Revision$ 6 | // 7 | 8 | using System; 9 | 10 | namespace ICSharpCode.TextEditor.Document 11 | { 12 | /// 13 | /// This interface is used to describe a span inside a text sequence 14 | /// 15 | public class AbstractSegment : ISegment 16 | { 17 | [CLSCompliant(false)] 18 | protected int offset = -1; 19 | [CLSCompliant(false)] 20 | protected int length = -1; 21 | 22 | #region ICSharpCode.TextEditor.Document.ISegment interface implementation 23 | public virtual int Offset { 24 | get { 25 | return offset; 26 | } 27 | set { 28 | offset = value; 29 | } 30 | } 31 | 32 | public virtual int Length { 33 | get { 34 | return length; 35 | } 36 | set { 37 | length = value; 38 | } 39 | } 40 | 41 | #endregion 42 | 43 | public override string ToString() 44 | { 45 | return String.Format("[AbstractSegment: Offset = {0}, Length = {1}]", 46 | Offset, 47 | Length); 48 | } 49 | 50 | 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Document/BookmarkManager/BookmarkEventHandler.cs: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | // 5 | // $Revision$ 6 | // 7 | 8 | using System; 9 | 10 | namespace ICSharpCode.TextEditor.Document 11 | { 12 | public delegate void BookmarkEventHandler(object sender, BookmarkEventArgs e); 13 | 14 | /// 15 | /// Description of BookmarkEventHandler. 16 | /// 17 | public class BookmarkEventArgs : EventArgs 18 | { 19 | Bookmark bookmark; 20 | 21 | public Bookmark Bookmark { 22 | get { 23 | return bookmark; 24 | } 25 | } 26 | 27 | public BookmarkEventArgs(Bookmark bookmark) 28 | { 29 | this.bookmark = bookmark; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Document/FoldingStrategy/IFoldingStrategy.cs: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | // 5 | // $Revision$ 6 | // 7 | 8 | using System; 9 | using System.Collections.Generic; 10 | 11 | namespace ICSharpCode.TextEditor.Document 12 | { 13 | /// 14 | /// This interface is used for the folding capabilities 15 | /// of the textarea. 16 | /// 17 | public interface IFoldingStrategy 18 | { 19 | /// 20 | /// Calculates the fold level of a specific line. 21 | /// 22 | List GenerateFoldMarkers(IDocument document, string fileName, object parseInformation); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Document/FoldingStrategy/IndentFoldingStrategy.cs: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | // 5 | // $Revision$ 6 | // 7 | 8 | using System; 9 | using System.Collections.Generic; 10 | 11 | namespace ICSharpCode.TextEditor.Document 12 | { 13 | /// 14 | /// A simple folding strategy which calculates the folding level 15 | /// using the indent level of the line. 16 | /// 17 | public class IndentFoldingStrategy : IFoldingStrategy 18 | { 19 | public List GenerateFoldMarkers(IDocument document, string fileName, object parseInformation) 20 | { 21 | List l = new List(); 22 | //Stack offsetStack = new Stack(); 23 | //Stack textStack = new Stack(); 24 | //int level = 0; 25 | //foreach (LineSegment segment in document.LineSegmentCollection) { 26 | // 27 | //} 28 | return l; 29 | } 30 | 31 | int GetLevel(IDocument document, int offset) 32 | { 33 | int level = 0; 34 | int spaces = 0; 35 | for (int i = offset; i < document.TextLength; ++i) { 36 | char c = document.GetCharAt(i); 37 | if (c == '\t' || (c == ' ' && ++spaces == 4)) { 38 | spaces = 0; 39 | ++level; 40 | } else { 41 | break; 42 | } 43 | } 44 | return level; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/HighlightBackground.cs: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | // 5 | // $Revision$ 6 | // 7 | 8 | using System; 9 | using System.Drawing; 10 | using System.Xml; 11 | 12 | namespace ICSharpCode.TextEditor.Document 13 | { 14 | /// 15 | /// Extens the highlighting color with a background image. 16 | /// 17 | public class HighlightBackground : HighlightColor 18 | { 19 | Image backgroundImage; 20 | 21 | /// 22 | /// The image used as background 23 | /// 24 | public Image BackgroundImage { 25 | get { 26 | return backgroundImage; 27 | } 28 | } 29 | 30 | /// 31 | /// Creates a new instance of 32 | /// 33 | public HighlightBackground(XmlElement el) : base(el) 34 | { 35 | if (el.Attributes["image"] != null) { 36 | backgroundImage = new Bitmap(el.Attributes["image"].InnerText); 37 | } 38 | } 39 | 40 | /// 41 | /// Creates a new instance of 42 | /// 43 | public HighlightBackground(Color color, Color backgroundcolor, bool bold, bool italic) : base(color, backgroundcolor, bold, italic) 44 | { 45 | } 46 | 47 | public HighlightBackground(string systemColor, string systemBackgroundColor, bool bold, bool italic) : base(systemColor, systemBackgroundColor, bold, italic) 48 | { 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/HighlightInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | // 5 | // $Revision$ 6 | // 7 | 8 | using System; 9 | 10 | namespace ICSharpCode.TextEditor.Document 11 | { 12 | public class HighlightInfo 13 | { 14 | public bool BlockSpanOn = false; 15 | public bool Span = false; 16 | public Span CurSpan = null; 17 | 18 | public HighlightInfo(Span curSpan, bool span, bool blockSpanOn) 19 | { 20 | this.CurSpan = curSpan; 21 | this.Span = span; 22 | this.BlockSpanOn = blockSpanOn; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/HighlightingColorNotFoundException.cs: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | // 5 | // $Revision$ 6 | // 7 | 8 | using System; 9 | using System.Runtime.Serialization; 10 | 11 | namespace ICSharpCode.TextEditor.Document 12 | { 13 | [Serializable()] 14 | public class HighlightingColorNotFoundException : Exception 15 | { 16 | public HighlightingColorNotFoundException() : base() 17 | { 18 | } 19 | 20 | public HighlightingColorNotFoundException(string message) : base(message) 21 | { 22 | } 23 | 24 | public HighlightingColorNotFoundException(string message, Exception innerException) : base(message, innerException) 25 | { 26 | } 27 | 28 | protected HighlightingColorNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) 29 | { 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/HighlightingDefinitionInvalidException.cs: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | // 5 | // $Revision$ 6 | // 7 | 8 | using System; 9 | using System.Runtime.Serialization; 10 | 11 | namespace ICSharpCode.TextEditor.Document 12 | { 13 | /// 14 | /// Indicates that the highlighting definition that was tried to load was invalid. 15 | /// You get this exception only once per highlighting definition, after that the definition 16 | /// is replaced with the default highlighter. 17 | /// 18 | [Serializable()] 19 | public class HighlightingDefinitionInvalidException : Exception 20 | { 21 | public HighlightingDefinitionInvalidException() : base() 22 | { 23 | } 24 | 25 | public HighlightingDefinitionInvalidException(string message) : base(message) 26 | { 27 | } 28 | 29 | public HighlightingDefinitionInvalidException(string message, Exception innerException) : base(message, innerException) 30 | { 31 | } 32 | 33 | protected HighlightingDefinitionInvalidException(SerializationInfo info, StreamingContext context) : base(info, context) 34 | { 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/HighlightingStrategyFactory.cs: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | // 5 | // $Revision$ 6 | // 7 | 8 | using System; 9 | 10 | namespace ICSharpCode.TextEditor.Document 11 | { 12 | public class HighlightingStrategyFactory 13 | { 14 | public static IHighlightingStrategy CreateHighlightingStrategy() 15 | { 16 | return (IHighlightingStrategy)HighlightingManager.Manager.HighlightingDefinitions["Default"]; 17 | } 18 | 19 | public static IHighlightingStrategy CreateHighlightingStrategy(string name) 20 | { 21 | IHighlightingStrategy highlightingStrategy = HighlightingManager.Manager.FindHighlighter(name); 22 | 23 | if (highlightingStrategy == null) { 24 | return CreateHighlightingStrategy(); 25 | } 26 | return highlightingStrategy; 27 | } 28 | 29 | public static IHighlightingStrategy CreateHighlightingStrategyForFile(string fileName) 30 | { 31 | IHighlightingStrategy highlightingStrategy = HighlightingManager.Manager.FindHighlighterForFile(fileName); 32 | if (highlightingStrategy == null) { 33 | return CreateHighlightingStrategy(); 34 | } 35 | return highlightingStrategy; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/IHighlightingStrategy.cs: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | // 5 | // $Revision$ 6 | // 7 | 8 | using System; 9 | using System.Collections.Generic; 10 | 11 | namespace ICSharpCode.TextEditor.Document 12 | { 13 | /// 14 | /// A highlighting strategy for a buffer. 15 | /// 16 | public interface IHighlightingStrategy 17 | { 18 | /// 19 | /// The name of the highlighting strategy, must be unique 20 | /// 21 | string Name { 22 | get; 23 | } 24 | 25 | /// 26 | /// The file extenstions on which this highlighting strategy gets 27 | /// used 28 | /// 29 | string[] Extensions { 30 | get; 31 | } 32 | 33 | Dictionary Properties { 34 | get; 35 | } 36 | 37 | // returns special color. (BackGround Color, Cursor Color and so on) 38 | 39 | /// 40 | /// Gets the color of an Environment element. 41 | /// 42 | HighlightColor GetColorFor(string name); 43 | 44 | /// 45 | /// Used internally, do not call 46 | /// 47 | void MarkTokens(IDocument document, List lines); 48 | 49 | /// 50 | /// Used internally, do not call 51 | /// 52 | void MarkTokens(IDocument document); 53 | } 54 | 55 | public interface IHighlightingStrategyUsingRuleSets : IHighlightingStrategy 56 | { 57 | /// 58 | /// Used internally, do not call 59 | /// 60 | HighlightRuleSet GetRuleSet(Span span); 61 | 62 | /// 63 | /// Used internally, do not call 64 | /// 65 | HighlightColor GetColor(IDocument document, LineSegment keyWord, int index, int length); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/NextMarker.cs: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | // 5 | // $Revision$ 6 | // 7 | 8 | using System; 9 | using System.Xml; 10 | 11 | namespace ICSharpCode.TextEditor.Document 12 | { 13 | /// 14 | /// Used for mark next token 15 | /// 16 | public class NextMarker 17 | { 18 | string what; 19 | HighlightColor color; 20 | bool markMarker = false; 21 | 22 | /// 23 | /// String value to indicate to mark next token 24 | /// 25 | public string What { 26 | get { 27 | return what; 28 | } 29 | } 30 | 31 | /// 32 | /// Color for marking next token 33 | /// 34 | public HighlightColor Color { 35 | get { 36 | return color; 37 | } 38 | } 39 | 40 | /// 41 | /// If true the indication text will be marked with the same color 42 | /// too 43 | /// 44 | public bool MarkMarker { 45 | get { 46 | return markMarker; 47 | } 48 | } 49 | 50 | /// 51 | /// Creates a new instance of 52 | /// 53 | public NextMarker(XmlElement mark) 54 | { 55 | color = new HighlightColor(mark); 56 | what = mark.InnerText; 57 | if (mark.Attributes["markmarker"] != null) { 58 | markMarker = Boolean.Parse(mark.Attributes["markmarker"].InnerText); 59 | } 60 | } 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/PrevMarker.cs: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | // 5 | // $Revision$ 6 | // 7 | 8 | using System; 9 | using System.Xml; 10 | 11 | namespace ICSharpCode.TextEditor.Document 12 | { 13 | /// 14 | /// Used for mark previous token 15 | /// 16 | public class PrevMarker 17 | { 18 | string what; 19 | HighlightColor color; 20 | bool markMarker = false; 21 | 22 | /// 23 | /// String value to indicate to mark previous token 24 | /// 25 | public string What { 26 | get { 27 | return what; 28 | } 29 | } 30 | 31 | /// 32 | /// Color for marking previous token 33 | /// 34 | public HighlightColor Color { 35 | get { 36 | return color; 37 | } 38 | } 39 | 40 | /// 41 | /// If true the indication text will be marked with the same color 42 | /// too 43 | /// 44 | public bool MarkMarker { 45 | get { 46 | return markMarker; 47 | } 48 | } 49 | 50 | /// 51 | /// Creates a new instance of 52 | /// 53 | public PrevMarker(XmlElement mark) 54 | { 55 | color = new HighlightColor(mark); 56 | what = mark.InnerText; 57 | if (mark.Attributes["markmarker"] != null) { 58 | markMarker = Boolean.Parse(mark.Attributes["markmarker"].InnerText); 59 | } 60 | } 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/SyntaxModes/ISyntaxModeFileProvider.cs: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | // 5 | // $Revision$ 6 | // 7 | 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Xml; 11 | 12 | namespace ICSharpCode.TextEditor.Document 13 | { 14 | public interface ISyntaxModeFileProvider 15 | { 16 | ICollection SyntaxModes { 17 | get; 18 | } 19 | 20 | XmlTextReader GetSyntaxModeFile(SyntaxMode syntaxMode); 21 | void UpdateSyntaxModeList(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/SyntaxModes/ResourceSyntaxModeProvider.cs: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | // 5 | // $Revision$ 6 | // 7 | 8 | using System; 9 | using System.Collections.Generic; 10 | using System.IO; 11 | using System.Reflection; 12 | using System.Xml; 13 | 14 | namespace ICSharpCode.TextEditor.Document 15 | { 16 | public class ResourceSyntaxModeProvider : ISyntaxModeFileProvider 17 | { 18 | List syntaxModes = null; 19 | 20 | public ICollection SyntaxModes { 21 | get { 22 | return syntaxModes; 23 | } 24 | } 25 | 26 | public ResourceSyntaxModeProvider() 27 | { 28 | Assembly assembly = typeof(SyntaxMode).Assembly; 29 | Stream syntaxModeStream = assembly.GetManifestResourceStream("ICSharpCode.TextEditor.Resources.SyntaxModes.xml"); 30 | if (syntaxModeStream != null) { 31 | syntaxModes = SyntaxMode.GetSyntaxModes(syntaxModeStream); 32 | } else { 33 | syntaxModes = new List(); 34 | } 35 | } 36 | 37 | public XmlTextReader GetSyntaxModeFile(SyntaxMode syntaxMode) 38 | { 39 | Assembly assembly = typeof(SyntaxMode).Assembly; 40 | return new XmlTextReader(assembly.GetManifestResourceStream("ICSharpCode.TextEditor.Resources." + syntaxMode.FileName)); 41 | } 42 | 43 | public void UpdateSyntaxModeList() 44 | { 45 | // resources don't change during runtime 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Document/ISegment.cs: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | // 5 | // $Revision$ 6 | // 7 | 8 | using System.Collections.Generic; 9 | 10 | namespace ICSharpCode.TextEditor.Document 11 | { 12 | /// 13 | /// This interface is used to describe a span inside a text sequence 14 | /// 15 | public interface ISegment 16 | { 17 | /// 18 | /// The offset where the span begins 19 | /// 20 | int Offset { 21 | get; 22 | set; 23 | } 24 | 25 | /// 26 | /// The length of the span 27 | /// 28 | int Length { 29 | get; 30 | set; 31 | } 32 | } 33 | 34 | public class SegmentComparer : IComparer 35 | { 36 | public int Compare(ISegment x, ISegment y) 37 | { 38 | if (x == null) 39 | { 40 | if (y == null) 41 | { 42 | // If x is null and y is null, they're 43 | // equal. 44 | return 0; 45 | } 46 | else 47 | { 48 | // If x is null and y is not null, y 49 | // is greater. 50 | return -1; 51 | } 52 | } 53 | 54 | // If x is not null and y is null, x is greater. 55 | if (y == null) 56 | { 57 | return 1; 58 | } 59 | 60 | int retval = x.Offset.CompareTo(y.Offset); 61 | if (retval != 0) 62 | return retval; 63 | 64 | return x.Length.CompareTo(y.Length); 65 | } 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Document/LineManager/DeferredEventList.cs: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | // 5 | // $Revision$ 6 | // 7 | using System; 8 | using System.Collections.Generic; 9 | 10 | namespace ICSharpCode.TextEditor.Document 11 | { 12 | /// 13 | /// A list of events that are fired after the line manager has finished working. 14 | /// 15 | struct DeferredEventList 16 | { 17 | internal List removedLines; 18 | internal List textAnchor; 19 | 20 | public void AddRemovedLine(LineSegment line) 21 | { 22 | if (removedLines == null) 23 | removedLines = new List(); 24 | removedLines.Add(line); 25 | } 26 | 27 | public void AddDeletedAnchor(TextAnchor anchor) 28 | { 29 | if (textAnchor == null) 30 | textAnchor = new List(); 31 | textAnchor.Add(anchor); 32 | } 33 | 34 | public void RaiseEvents() 35 | { 36 | // removedLines is raised by the LineManager 37 | if (textAnchor != null) { 38 | foreach (TextAnchor a in textAnchor) { 39 | a.RaiseDeleted(); 40 | } 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Document/Selection/ColumnRange.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ICSharpCode.TextEditor.Document 4 | { 5 | public class ColumnRange 6 | { 7 | public static readonly ColumnRange NoColumn = new ColumnRange(-2, -2); 8 | public static readonly ColumnRange WholeColumn = new ColumnRange(-1, -1); 9 | 10 | int startColumn; 11 | int endColumn; 12 | 13 | public int StartColumn { 14 | get { 15 | return startColumn; 16 | } 17 | set { 18 | startColumn = value; 19 | } 20 | } 21 | 22 | public int EndColumn { 23 | get { 24 | return endColumn; 25 | } 26 | set { 27 | endColumn = value; 28 | } 29 | } 30 | 31 | public ColumnRange(int startColumn, int endColumn) 32 | { 33 | this.startColumn = startColumn; 34 | this.endColumn = endColumn; 35 | 36 | } 37 | 38 | public override int GetHashCode() 39 | { 40 | return startColumn + (endColumn << 16); 41 | } 42 | 43 | public override bool Equals(object obj) 44 | { 45 | if (obj is ColumnRange) { 46 | return ((ColumnRange)obj).startColumn == startColumn && 47 | ((ColumnRange)obj).endColumn == endColumn; 48 | 49 | } 50 | return false; 51 | } 52 | 53 | public override string ToString() 54 | { 55 | return String.Format("[ColumnRange: StartColumn={0}, EndColumn={1}]", startColumn, endColumn); 56 | } 57 | 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Document/Selection/ISelection.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | 3 | namespace ICSharpCode.TextEditor.Document 4 | { 5 | /// 6 | /// An interface representing a portion of the current selection. 7 | /// 8 | public interface ISelection 9 | { 10 | TextLocation StartPosition { 11 | get; 12 | set; 13 | } 14 | 15 | TextLocation EndPosition { 16 | get; 17 | set; 18 | } 19 | 20 | int Offset { 21 | get; 22 | } 23 | 24 | int EndOffset { 25 | get; 26 | } 27 | 28 | int Length { 29 | get; 30 | } 31 | 32 | /// 33 | /// Returns true, if the selection is rectangular 34 | /// 35 | bool IsRectangularSelection { 36 | get; 37 | } 38 | 39 | /// 40 | /// Returns true, if the selection is empty 41 | /// 42 | bool IsEmpty { 43 | get; 44 | } 45 | 46 | /// 47 | /// The text which is selected by this selection. 48 | /// 49 | string SelectedText { 50 | get; 51 | } 52 | 53 | bool ContainsOffset(int offset); 54 | 55 | bool ContainsPosition(TextLocation position); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Gui/BrushRegistry.cs: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | // 5 | // $Revision$ 6 | // 7 | 8 | using System; 9 | using System.Collections; 10 | using System.Collections.Generic; 11 | using System.Drawing; 12 | using System.Drawing.Drawing2D; 13 | 14 | namespace ICSharpCode.TextEditor 15 | { 16 | /// 17 | /// Contains brushes/pens for the text editor to speed up drawing. Re-Creation of brushes and pens 18 | /// seems too costly. 19 | /// 20 | public class BrushRegistry 21 | { 22 | static Dictionary brushes = new Dictionary(); 23 | static Dictionary pens = new Dictionary(); 24 | static Dictionary dotPens = new Dictionary(); 25 | 26 | public static Brush GetBrush(Color color) 27 | { 28 | lock (brushes) { 29 | Brush brush; 30 | if (!brushes.TryGetValue(color, out brush)) { 31 | brush = new SolidBrush(color); 32 | brushes.Add(color, brush); 33 | } 34 | return brush; 35 | } 36 | } 37 | 38 | public static Pen GetPen(Color color) 39 | { 40 | lock (pens) { 41 | Pen pen; 42 | if (!pens.TryGetValue(color, out pen)) { 43 | pen = new Pen(color); 44 | pens.Add(color, pen); 45 | } 46 | return pen; 47 | } 48 | } 49 | 50 | static readonly float[] dotPattern = { 1, 1, 1, 1 }; 51 | 52 | public static Pen GetDotPen(Color color) 53 | { 54 | lock (dotPens) { 55 | Pen pen; 56 | if (!dotPens.TryGetValue(color, out pen)) { 57 | pen = new Pen(color); 58 | pen.DashPattern = dotPattern; 59 | dotPens.Add(color, pen); 60 | } 61 | return pen; 62 | } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Gui/HRuler.cs: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | // 5 | // $Revision$ 6 | // 7 | 8 | using System; 9 | using System.Drawing; 10 | using System.Windows.Forms; 11 | 12 | namespace ICSharpCode.TextEditor 13 | { 14 | /// 15 | /// Horizontal ruler - text column measuring ruler at the top of the text area. 16 | /// 17 | public class HRuler : Control 18 | { 19 | TextArea textArea; 20 | 21 | public HRuler(TextArea textArea) 22 | { 23 | this.textArea = textArea; 24 | } 25 | 26 | protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) 27 | { 28 | Graphics g = e.Graphics; 29 | int num = 0; 30 | for (float x = textArea.TextView.DrawingPosition.Left; x < textArea.TextView.DrawingPosition.Right; x += textArea.TextView.WideSpaceWidth) { 31 | int offset = (Height * 2) / 3; 32 | if (num % 5 == 0) { 33 | offset = (Height * 4) / 5; 34 | } 35 | 36 | if (num % 10 == 0) { 37 | offset = 1; 38 | } 39 | ++num; 40 | g.DrawLine(Pens.Black, 41 | (int)x, offset, (int)x, Height - offset); 42 | } 43 | } 44 | 45 | protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs e) 46 | { 47 | e.Graphics.FillRectangle(Brushes.White, 48 | new Rectangle(0, 49 | 0, 50 | Width, 51 | Height)); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Gui/ToolTipRequestEventArgs.cs: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | // 5 | // $Revision$ 6 | // 7 | 8 | using System; 9 | using System.Drawing; 10 | 11 | namespace ICSharpCode.TextEditor 12 | { 13 | public delegate void ToolTipRequestEventHandler(object sender, ToolTipRequestEventArgs e); 14 | 15 | public class ToolTipRequestEventArgs 16 | { 17 | Point mousePosition; 18 | TextLocation logicalPosition; 19 | bool inDocument; 20 | 21 | public Point MousePosition { 22 | get { 23 | return mousePosition; 24 | } 25 | } 26 | 27 | public TextLocation LogicalPosition { 28 | get { 29 | return logicalPosition; 30 | } 31 | } 32 | 33 | public bool InDocument { 34 | get { 35 | return inDocument; 36 | } 37 | } 38 | 39 | /// 40 | /// Gets if some client handling the event has already shown a tool tip. 41 | /// 42 | public bool ToolTipShown { 43 | get { 44 | return toolTipText != null; 45 | } 46 | } 47 | 48 | internal string toolTipText; 49 | 50 | public void ShowToolTip(string text) 51 | { 52 | toolTipText = text; 53 | } 54 | 55 | public ToolTipRequestEventArgs(Point mousePosition, TextLocation logicalPosition, bool inDocument) 56 | { 57 | this.mousePosition = mousePosition; 58 | this.logicalPosition = logicalPosition; 59 | this.inDocument = inDocument; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Undo/IUndoableOperation.cs: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | // 5 | // $Revision$ 6 | // 7 | 8 | namespace ICSharpCode.TextEditor.Undo 9 | { 10 | /// 11 | /// This Interface describes a the basic Undo/Redo operation 12 | /// all Undo Operations must implement this interface. 13 | /// 14 | public interface IUndoableOperation 15 | { 16 | /// 17 | /// Undo the last operation 18 | /// 19 | void Undo(); 20 | 21 | /// 22 | /// Redo the last operation 23 | /// 24 | void Redo(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Undo/UndoQueue.cs: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | // 5 | // $Revision$ 6 | // 7 | 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Diagnostics; 11 | 12 | namespace ICSharpCode.TextEditor.Undo 13 | { 14 | /// 15 | /// This class stacks the last x operations from the undostack and makes 16 | /// one undo/redo operation from it. 17 | /// 18 | internal sealed class UndoQueue : IUndoableOperation 19 | { 20 | List undolist = new List(); 21 | 22 | /// 23 | /// 24 | public UndoQueue(Stack stack, int numops) 25 | { 26 | if (stack == null) { 27 | throw new ArgumentNullException("stack"); 28 | } 29 | 30 | Debug.Assert(numops > 0 , "ICSharpCode.TextEditor.Undo.UndoQueue : numops should be > 0"); 31 | if (numops > stack.Count) { 32 | numops = stack.Count; 33 | } 34 | 35 | for (int i = 0; i < numops; ++i) { 36 | undolist.Add(stack.Pop()); 37 | } 38 | } 39 | public void Undo() 40 | { 41 | for (int i = 0; i < undolist.Count; ++i) { 42 | undolist[i].Undo(); 43 | } 44 | } 45 | 46 | public void Redo() 47 | { 48 | for (int i = undolist.Count - 1 ; i >= 0 ; --i) { 49 | undolist[i].Redo(); 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Util/LoggingService.cs: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | // 5 | // $Revision$ 6 | // 7 | 8 | using System; 9 | 10 | namespace ICSharpCode.TextEditor.Util 11 | { 12 | /// 13 | /// Central location for logging calls in the text editor. 14 | /// 15 | static class LoggingService 16 | { 17 | public static void Debug(string text) 18 | { 19 | #if DEBUG 20 | Console.WriteLine(text); 21 | #endif 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Util/MouseWheelHandler.cs: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | // 5 | // $Revision$ 6 | // 7 | 8 | using System; 9 | using System.Windows.Forms; 10 | 11 | namespace ICSharpCode.TextEditor.Util 12 | { 13 | /// 14 | /// Accumulates mouse wheel deltas and reports the actual number of lines to scroll. 15 | /// 16 | class MouseWheelHandler 17 | { 18 | // CODE DUPLICATION: See ICSharpCode.SharpDevelop.Widgets.MouseWheelHandler 19 | 20 | const int WHEEL_DELTA = 120; 21 | 22 | int mouseWheelDelta; 23 | 24 | public int GetScrollAmount(MouseEventArgs e) 25 | { 26 | // accumulate the delta to support high-resolution mice 27 | mouseWheelDelta += e.Delta; 28 | 29 | int linesPerClick = Math.Max(SystemInformation.MouseWheelScrollLines, 1); 30 | 31 | int scrollDistance = mouseWheelDelta * linesPerClick / WHEEL_DELTA; 32 | mouseWheelDelta %= Math.Max(1, WHEEL_DELTA / linesPerClick); 33 | return scrollDistance; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Project/Src/Util/TipSpacer.cs: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | // 5 | // $Revision$ 6 | // 7 | 8 | using System; 9 | using System.Drawing; 10 | 11 | namespace ICSharpCode.TextEditor.Util 12 | { 13 | class TipSpacer: TipSection 14 | { 15 | SizeF spacerSize; 16 | 17 | public TipSpacer(Graphics graphics, SizeF size): base(graphics) 18 | { 19 | spacerSize = size; 20 | } 21 | 22 | public override void Draw(PointF location) 23 | { 24 | 25 | } 26 | 27 | protected override void OnMaximumSizeChanged() 28 | { 29 | base.OnMaximumSizeChanged(); 30 | 31 | SetRequiredSize(new SizeF 32 | (Math.Min(MaximumSize.Width, spacerSize.Width), 33 | Math.Min(MaximumSize.Height, spacerSize.Height))); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Test/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | // 5 | // $Revision$ 6 | // 7 | 8 | using System.Reflection; 9 | using System.Runtime.CompilerServices; 10 | 11 | // Information about this assembly is defined by the following 12 | // attributes. 13 | // 14 | // change them to the information which is associated with the assembly 15 | // you compile. 16 | 17 | [assembly: AssemblyTitle("")] 18 | [assembly: AssemblyDescription("")] 19 | [assembly: AssemblyConfiguration("")] 20 | [assembly: AssemblyCompany("")] 21 | [assembly: AssemblyProduct("")] 22 | [assembly: AssemblyCopyright("")] 23 | [assembly: AssemblyTrademark("")] 24 | [assembly: AssemblyCulture("")] 25 | 26 | // The assembly version has following format : 27 | // 28 | // Major.Minor.Build.Revision 29 | // 30 | // You can specify all values by your own or you can build default build and revision 31 | // numbers with the '*' character (the default): 32 | 33 | [assembly: AssemblyVersion("2.0.0.1")] 34 | 35 | // The following attributes specify the key for the sign of your assembly. See the 36 | // .NET Framework documentation for more information about signing. 37 | // This is not required, if you don't want signing let these attributes like they're. 38 | [assembly: AssemblyDelaySign(false)] 39 | [assembly: AssemblyKeyFile("")] 40 | -------------------------------------------------------------------------------- /Main/ICSharpCode.TextEditor/Test/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Main/LLLPG/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Main/LLLPG/LLLPG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Main/LLLPG/LLLPG.png -------------------------------------------------------------------------------- /Main/LLLPG/OpenSourceKey.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Main/LLLPG/OpenSourceKey.snk -------------------------------------------------------------------------------- /Main/LLLPG/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("LLLPG")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("LLLPG")] 13 | [assembly: AssemblyCopyright("Copyright © 2016 David Piepgrass")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("275f6dd0-76e5-425a-9fe3-f7c3467aeaee")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion ("2.5.1.0")] 36 | [assembly: AssemblyFileVersion("2.5.1.0")] 37 | -------------------------------------------------------------------------------- /Main/LeMP.StdMacros/CSharpForwardPipeArrow.cs: -------------------------------------------------------------------------------- 1 | using Loyc.Syntax; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace LeMP 9 | { 10 | partial class StandardMacros 11 | { 12 | /*[LexicalMacro(@"A |> B; A ?|> B", 13 | @"Computes A and sends the result into B, e.g. `msg |> Console.WriteLine` means " + 14 | @"`Console.WriteLine(msg)`. If `B` contains `#`, it represents the result of `A`, " + 15 | @"e.g. `PI * r**2 |> Foo(#, #)` would mean `Foo((PI * r**2)::temp, temp)`. " + 16 | @"`A ?|> B` operator computes B only when A is not null, e.g. " + 17 | @"`x ?|> Math.Sin` means `x != null ? Math.Sin(x ?? default) : null`.", 18 | "'?|>")] 19 | public static LNode ForwardPipeOperator(LNode node, IMacroContext context) 20 | { 21 | 22 | if (nameof.ArgCount != 1) 23 | return null; 24 | Symbol expr = EcsValidators.KeyNameComponentOf(nameof.Args[0]); 25 | return F.Literal(expr.Name); 26 | } 27 | 28 | [LexicalMacro(@"A ?|> B", 29 | @"Computes A and sends the result into B, e.g. `msg |> Console.WriteLine` means " + 30 | @"`Console.WriteLine(msg)`. If `B` contains `#`, it represents the result of `A`, " + 31 | @"e.g. `PI * r**2 |> Foo(#, #)` would mean `Foo((PI * r**2)::temp, temp)`. " + 32 | @"`A ?|> B` operator computes B only when A is not null, e.g. " + 33 | @"`x ?|> Math.Sin` means `x != null ? Math.Sin(x ?? default) : null`.", 34 | "'?|>")] 35 | public static LNode NullForwardPipeOperator(LNode node, IMacroContext context) 36 | { 37 | 38 | if (nameof.ArgCount != 1) 39 | return null; 40 | Symbol expr = EcsValidators.KeyNameComponentOf(nameof.Args[0]); 41 | return F.Literal(expr.Name); 42 | }*/ 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Main/LeMP.StdMacros/OpenSourceKey.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Main/LeMP.StdMacros/OpenSourceKey.snk -------------------------------------------------------------------------------- /Main/LeMP.StdMacros/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("LeMP Standard Macros")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("LeMP.StdMacros")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("66f7c719-8c78-49c6-9053-582a920e4aaa")] 23 | 24 | // In case needed by unit tests 25 | [assembly: InternalsVisibleTo("LeMP, PublicKey=0024000004800000940000000602000000240000525341310004000001000100adec5c8e52098b94dc60b34ac0916d307eec23b2c285a0beeb7168174fc1f6a71dcae43c88904e2907a12f66861de8d8f130c4f7b57cff0aea92ed06b50d96c63cea2ee19ec5d35a2946ddef3f35f0fbd3ec3a358b46fd05c82837c49d91694c1926935dc83e2a28c1ff077e4d8a5f679f1edb1c8a692aa2913d753ea05f4fba")] 26 | -------------------------------------------------------------------------------- /Main/LeMP.StdMacros/ecs/ThisConstructorMacro.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Loyc; 6 | using Loyc.Collections; 7 | using Loyc.Syntax; 8 | using Loyc.Ecs; 9 | using S = Loyc.Syntax.CodeSymbols; 10 | 11 | namespace LeMP.ecs 12 | { 13 | partial class StandardMacros 14 | { 15 | // TODO: support "attribute" macros. 16 | [LexicalMacro("class Foo { this() {} }", 17 | "Supports the EC# 'this()' syntax for constructors by replacing 'this' with the name of the enclosing class.", 18 | "#cons", Mode = MacroMode.Passive | MacroMode.Normal | MacroMode.PriorityOverride)] 19 | public static LNode Constructor(LNode cons, IMacroContext context) 20 | { 21 | if (cons.ArgCount >= 3 && cons.Args[1].IsIdNamed(S.This)) 22 | { 23 | var anc = context.Ancestors; 24 | LNode space = anc.TryGet(anc.Count - 3, LNode.Missing), typeName; 25 | Symbol type = EcsValidators.SpaceDefinitionKind(space); 26 | if (type != null && anc[anc.Count - 2] == space.Args[2]) { 27 | typeName = space.Args[0]; 28 | return cons.WithArgChanged(1, F.Id(KeyNameComponentOf(typeName))); 29 | } 30 | } 31 | return null; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Main/LeMP.StdMacros/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Main/LeMP/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Main/LeMP/DotnetToolSettings.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Main/LeMP/EC#.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Main/LeMP/EC#.ico -------------------------------------------------------------------------------- /Main/LeMP/EC#.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Main/LeMP/EC#.pdn -------------------------------------------------------------------------------- /Main/LeMP/LeMP.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netcoreapp2.0 4 | 5 | Exe 6 | ..\..\Bin\$(Configuration)\ 7 | 1591, 1573, 0419, 1587 8 | true 9 | OpenSourceKey.snk 10 | false 11 | 12 | 13 | true 14 | ..\..\Bin\$(Configuration)\$(TargetFramework)\LeMP.XML 15 | 16 | 17 | TRACE;NoReflectionEmit 18 | 19 | 20 | TRACE;NoReflectionEmit 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Main/LeMP/OpenSourceKey.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Main/LeMP/OpenSourceKey.snk -------------------------------------------------------------------------------- /Main/LeMP/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("LeMP: Loyc Lexical Macro Processor")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Principal Author: David Piepgrass")] 12 | [assembly: AssemblyProduct("LeMP")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("a2c32367-14d0-41ca-b415-c764ff37e10e")] 23 | -------------------------------------------------------------------------------- /Main/LeMP/Tests/CompilerTests.cs: -------------------------------------------------------------------------------- 1 | using Loyc; 2 | using Loyc.MiniTest; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Text; 8 | 9 | namespace LeMP.Tests 10 | { 11 | // Tests the top-level Compiler class. TODO: more testing! 12 | [TestFixture] 13 | public class CompilerTests 14 | { 15 | [Test] 16 | public void TestAutoOpenedNamespaceByExtension() 17 | { 18 | // LeMP should open LeMP.ecs for .ecs files, but not for .les files. 19 | // As an EC# macro, `quote` will work in .ecs but not .les. 20 | var c = new Compiler(MessageSink.Default, typeof(LeMP.Prelude.BuiltinMacros)); 21 | 22 | var fileName1 = Path.GetTempFileName(); 23 | File.WriteAllText(fileName1, "define foo() { goo(); };\nfoo();\nquote(hoo);"); 24 | var fileName2 = Path.ChangeExtension(Path.GetTempFileName(), "ecs"); 25 | File.WriteAllText(fileName2, "define foo() { koo(); }\nfoo();\nquote(loo);"); 26 | 27 | // --inlang:les2 affects only the first file (.tmp); language is autodetected for .ecs 28 | // (--forcelang is needed to override this behavior) 29 | var opts = c.ProcessArguments(new List { fileName1, fileName2, "--inlang:les2", "--outext:cs" }, true, true); 30 | c.Run(); 31 | 32 | var result1 = File.ReadAllText(Path.ChangeExtension(fileName1, "cs")); 33 | Assert.AreEqual("goo();\nquote(hoo);", result1); 34 | var result2 = File.ReadAllText(Path.ChangeExtension(fileName2, "cs")); 35 | Assert.AreEqual("koo();\nLNode.Id((Symbol) \"loo\");", result2); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Main/LeMP/Tests/TestUnrollMacro.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Loyc.MiniTest; 6 | 7 | namespace LeMP.Tests 8 | { 9 | [TestFixture] 10 | public class TestUnrollMacro : MacroTesterBase 11 | { 12 | [Test] 13 | public void TestUnroll() 14 | { 15 | TestLes(@"unroll X `in` (X; Y) { sum += X; }", 16 | "sum += X; sum += Y;"); 17 | TestBoth(@"unroll X `in` (X; Y) { sum += X; }", 18 | "unroll (X in (X, Y)) { sum += X; }", 19 | "sum += X; sum += Y;"); 20 | TestEcs("unroll (X in (X, Y)) { sum += X; Console.WriteLine(sum); }", 21 | "sum += X; Console.WriteLine(sum);" + 22 | "sum += Y; Console.WriteLine(sum);"); 23 | TestEcs("unroll (X in (A(), [Oof] B)) { X(X, [Foo] X); }", 24 | "A()(A(), [Foo] A());" + 25 | "([Oof] B)([Oof] B, [Foo, Oof] B);"); 26 | TestEcs("unroll ((type, name) in ((int, x), (uint, y), (float, z))) { type name = 0; }", 27 | "int x = 0; " + 28 | "uint y = 0; " + 29 | "float z = 0;"); 30 | TestEcs("unroll (X in (int X = 41, X++, Console.WriteLine(X))) { X; }", 31 | "int X = 41; X++; Console.WriteLine(X);"); 32 | } 33 | [Test] 34 | public void TestUnrollWithBraces() 35 | { 36 | TestEcs("unroll (Var in { int X; float Y; string Z; }) { internal static Var; }", 37 | "internal static int X; internal static float Y; internal static string Z;"); 38 | } 39 | [Test] 40 | public void TestUnrollPreservesTrivia() 41 | { 42 | TestEcs(@"/*before*/ 43 | unroll (Var in { int X; float Y; string Z; }) { 44 | internal static Var; 45 | } /*after*/", 46 | @"/*before*/ 47 | internal static int X; 48 | internal static float Y; 49 | internal static string Z; /*after*/"); 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /Main/LeMPDemo/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Main/LeMPDemo/EC#.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertie/ecsharp/9fc22ca0ba73c4c2b73ad70b4017f2c254d701ee/Main/LeMPDemo/EC#.ico -------------------------------------------------------------------------------- /Main/LeMPDemo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace LeMPDemo 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | System.Windows.Forms.Application.EnableVisualStyles(); 18 | System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); 19 | System.Windows.Forms.Application.Run(new TextEditor.LempDemoForm()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Main/Tests/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Main/Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Loyc Main Tests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Tests")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("d418ccf8-0888-4648-a865-702a21273028")] 23 | -------------------------------------------------------------------------------- /UpdateLibLeMPAndReinstall.bat: -------------------------------------------------------------------------------- 1 | REM This script builds the extension (vsix file) for Visual Studio 2022, 2 | REM copies it to Lib/LeMP and then starts the vsix file. 3 | REM Note: Any previously installed vsix must first be uninstalled manually 4 | REM from within VS. 5 | "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\devenv.exe" /out vsbuild.log /build Release "Loyc.netfx.sln" 6 | @IF ERRORLEVEL 1 GOTO ERROR 7 | mkdir Lib\LeMP 8 | copy Bin\Release\*.dll Lib\LeMP 9 | @IF ERRORLEVEL 1 GOTO ERROR 10 | copy Bin\Release\*.exe Lib\LeMP 11 | @IF ERRORLEVEL 1 GOTO ERROR 12 | copy Bin\Release\*.xml Lib\LeMP 13 | copy Bin\Release\*.pdb Lib\LeMP 14 | copy Bin\Release\*.exe.config Lib\LeMP 15 | 16 | "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\devenv.exe" /out vsbuild.log /build Debug "Visual Studio Integration\Visual Studio Integration 2022.sln" 17 | @echo off 18 | @IF ERRORLEVEL 1 GOTO ERROR 19 | 20 | copy "Visual Studio Integration\LoycForVS2022\bin\Debug\LeMP_VisualStudio.vsix" "Lib\LeMP" 21 | @IF ERRORLEVEL 1 GOTO ERROR 22 | 23 | "Lib\LeMP\LeMP_VisualStudio.vsix" 24 | pause 25 | GOTO STOP 26 | 27 | :ERROR 28 | @echo ********************** 29 | @echo *** ERROR OCCURRED *** 30 | @echo ********************** 31 | @if exist vsbuild.log type vsbuild.log 32 | pause 33 | 34 | :STOP 35 | if exist vsbuild.log del vsbuild.log 36 | -------------------------------------------------------------------------------- /Visual Studio Integration/Example.les: -------------------------------------------------------------------------------- 1 | // LES code 2 | import System; 3 | namespace Bar { 4 | class RandomTest { LLLPG { 5 | rule Food @[ "pizza" | "lasagna" ]; 6 | }}; 7 | }; 8 | -------------------------------------------------------------------------------- /Visual Studio Integration/Example.samplelang: -------------------------------------------------------------------------------- 1 |  2 | Open this in Visual Studio to see "sample" syntax highlighting. 3 | // Backslashes are underlined. 4 | \\ <-- Such as those ones. 5 | When you start a parenthetical (like this) the parens are highlighted, 6 | but ([nested parens (like this)]) are not highlighted. 7 | # Do not write a closing ")" without an opening "(". 8 | etc. 9 | -------------------------------------------------------------------------------- /Visual Studio Integration/LoycForVS2022/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("LeMP Custom Tool")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("LeMP Custom Tool")] 13 | [assembly: AssemblyCopyright("")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | //[assembly: AssemblyVersion("1.0.0.0")] 23 | //[assembly: AssemblyFileVersion("1.0.0.0")] 24 | -------------------------------------------------------------------------------- /Visual Studio Integration/LoycForVS2022/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Visual Studio Integration/LoycForVS2022/source.extension.vsixmanifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | LeMP Custom Tool 6 | The LeMP and LLLPG single-file generators, with syntax highlighting for .ecs (Enhanced C#) and .les files. 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Visual Studio Integration/Visual Studio Integration 2022.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LeMP_VisualStudio", "LoycForVS2022\LeMP_VisualStudio.csproj", "{FA6768BC-5ECA-4D36-95E5-EF8F07A4C37F}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {FA6768BC-5ECA-4D36-95E5-EF8F07A4C37F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {FA6768BC-5ECA-4D36-95E5-EF8F07A4C37F}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {FA6768BC-5ECA-4D36-95E5-EF8F07A4C37F}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {FA6768BC-5ECA-4D36-95E5-EF8F07A4C37F}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | --------------------------------------------------------------------------------