You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ATTRIB 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. ============
  2. These pieces of code were ported from dotnet/corefx:
  3. syntax/charclass.go (from RegexCharClass.cs): ported to use the built-in Go unicode classes. Canonicalize is
  4. a direct port, but most of the other code required large changes because the C# implementation
  5. used a string to represent the CharSet data structure and I cleaned that up in my implementation.
  6. syntax/code.go (from RegexCode.cs): ported literally with various cleanups and layout to make it more Go-ish.
  7. syntax/escape.go (from RegexParser.cs): ported Escape method and added some optimizations. Unescape is inspired by
  8. the C# implementation but couldn't be directly ported because of the lack of do-while syntax in Go.
  9. syntax/parser.go (from RegexpParser.cs and RegexOptions.cs): ported parser struct and associated methods as
  10. literally as possible. Several language differences required changes. E.g. lack pre/post-fix increments as
  11. expressions, lack of do-while loops, lack of overloads, etc.
  12. syntax/prefix.go (from RegexFCD.cs and RegexBoyerMoore.cs): ported as literally as possible and added support
  13. for unicode chars that are longer than the 16-bit char in C# for the 32-bit rune in Go.
  14. syntax/replacerdata.go (from RegexReplacement.cs): conceptually ported and re-organized to handle differences
  15. in charclass implementation, and fix odd code layout between RegexParser.cs, Regex.cs, and RegexReplacement.cs.
  16. syntax/tree.go (from RegexTree.cs and RegexNode.cs): ported literally as possible.
  17. syntax/writer.go (from RegexWriter.cs): ported literally with minor changes to make it more Go-ish.
  18. match.go (from RegexMatch.cs): ported, simplified, and changed to handle Go's lack of inheritence.
  19. regexp.go (from Regex.cs and RegexOptions.cs): conceptually serves the same "starting point", but is simplified
  20. and changed to handle differences in C# strings and Go strings/runes.
  21. replace.go (from RegexReplacement.cs): ported closely and then cleaned up to combine the MatchEvaluator and
  22. simple string replace implementations.
  23. runner.go (from RegexRunner.cs): ported literally as possible.
  24. regexp_test.go (from CaptureTests.cs and GroupNamesAndNumbers.cs): conceptually ported, but the code was
  25. manually structured like Go tests.
  26. replace_test.go (from RegexReplaceStringTest0.cs): conceptually ported
  27. rtl_test.go (from RightToLeft.cs): conceptually ported
  28. ---
  29. dotnet/corefx was released under this license:
  30. The MIT License (MIT)
  31. Copyright (c) Microsoft Corporation
  32. Permission is hereby granted, free of charge, to any person obtaining a copy
  33. of this software and associated documentation files (the "Software"), to deal
  34. in the Software without restriction, including without limitation the rights
  35. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  36. copies of the Software, and to permit persons to whom the Software is
  37. furnished to do so, subject to the following conditions:
  38. The above copyright notice and this permission notice shall be included in all
  39. copies or substantial portions of the Software.
  40. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  41. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  42. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  43. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  44. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  45. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  46. SOFTWARE.
  47. ============
  48. These pieces of code are copied from the Go framework:
  49. - The overall directory structure of regexp2 was inspired by the Go runtime regexp package.
  50. - The optimization in the escape method of syntax/escape.go is from the Go runtime QuoteMeta() func in regexp/regexp.go
  51. - The method signatures in regexp.go are designed to match the Go framework regexp methods closely
  52. - func regexp2.MustCompile and func quote are almost identifical to the regexp package versions
  53. - BenchmarkMatch* and TestProgramTooLong* funcs in regexp_performance_test.go were copied from the framework
  54. regexp/exec_test.go
  55. ---
  56. The Go framework was released under this license:
  57. Copyright (c) 2012 The Go Authors. All rights reserved.
  58. Redistribution and use in source and binary forms, with or without
  59. modification, are permitted provided that the following conditions are
  60. met:
  61. * Redistributions of source code must retain the above copyright
  62. notice, this list of conditions and the following disclaimer.
  63. * Redistributions in binary form must reproduce the above
  64. copyright notice, this list of conditions and the following disclaimer
  65. in the documentation and/or other materials provided with the
  66. distribution.
  67. * Neither the name of Google Inc. nor the names of its
  68. contributors may be used to endorse or promote products derived from
  69. this software without specific prior written permission.
  70. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  71. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  72. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  73. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  74. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  75. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  76. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  77. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  78. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  79. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  80. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  81. ============
  82. Some test data were gathered from the Mono project.
  83. regexp_mono_test.go: ported from https://github.com/mono/mono/blob/master/mcs/class/System/Test/System.Text.RegularExpressions/PerlTrials.cs
  84. ---
  85. Mono tests released under this license:
  86. Permission is hereby granted, free of charge, to any person obtaining
  87. a copy of this software and associated documentation files (the
  88. "Software"), to deal in the Software without restriction, including
  89. without limitation the rights to use, copy, modify, merge, publish,
  90. distribute, sublicense, and/or sell copies of the Software, and to
  91. permit persons to whom the Software is furnished to do so, subject to
  92. the following conditions:
  93. The above copyright notice and this permission notice shall be
  94. included in all copies or substantial portions of the Software.
  95. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  96. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  97. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  98. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  99. LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  100. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  101. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.