Snippets

Patrick Logan FP in Go is not bad considering the simple rules it presents

Updated by Patrick Logan

File snippet.go Modified

  • Ignore whitespace
  • Hide word diff
 	// This is from an N-Triples format parser, using a parsing combinator library I wrote.
 	// This parses and decodes encodings of unicode such as \u1D740 and \UF0908D88 and the escapable N-Triple characters t, b, n, r, f, ", ', and \
-	unicode4 = pr.WithAction(pr.And(backslash, lowerU, pr.WithAction(pr.N(pr.HexDigit, 4), pr.ConcatAction)), pr.Compose(pr.Third, hex(4)))
-	unicode8 = pr.WithAction(pr.And(backslash, upperU, pr.WithAction(pr.N(pr.HexDigit, 8), pr.ConcatAction)), pr.Compose(pr.Third, hex(8)))
+	unicode4 = pr.WithAction(pr.And(backslash, lowerU, pr.NString(pr.HexDigit, 4)), pr.Compose(pr.Third, hex(4)))
+	unicode8 = pr.WithAction(pr.And(backslash, upperU, pr.NString(pr.HexDigit, 8)), pr.Compose(pr.Third, hex(8)))
 	escapeChar = pr.Or(lowerT, lowerB, lowerN, lowerR, lowerF, doubleQuote, singleQuote, backslash)
 	escaped = pr.WithAction(pr.And(backslash, escapeChar), pr.Compose(pr.Second, decodeEscape))
Updated by Patrick Logan

File snippet.go Modified

  • Ignore whitespace
  • Hide word diff
 	// This is from an N-Triples format parser, using a parsing combinator library I wrote.
-	// This parses encodings of unicode such as \u1D740 and \UF0908D88 and the escapable N-Triple characters t, b, n, r, f, ", ', and \
+	// This parses and decodes encodings of unicode such as \u1D740 and \UF0908D88 and the escapable N-Triple characters t, b, n, r, f, ", ', and \
 	unicode4 = pr.WithAction(pr.And(backslash, lowerU, pr.WithAction(pr.N(pr.HexDigit, 4), pr.ConcatAction)), pr.Compose(pr.Third, hex(4)))
 	unicode8 = pr.WithAction(pr.And(backslash, upperU, pr.WithAction(pr.N(pr.HexDigit, 8), pr.ConcatAction)), pr.Compose(pr.Third, hex(8)))
 	escapeChar = pr.Or(lowerT, lowerB, lowerN, lowerR, lowerF, doubleQuote, singleQuote, backslash)
Updated by Patrick Logan

File snippet.go Modified

  • Ignore whitespace
  • Hide word diff
+	// This is from an N-Triples format parser, using a parsing combinator library I wrote.
+	// This parses encodings of unicode such as \u1D740 and \UF0908D88 and the escapable N-Triple characters t, b, n, r, f, ", ', and \
 	unicode4 = pr.WithAction(pr.And(backslash, lowerU, pr.WithAction(pr.N(pr.HexDigit, 4), pr.ConcatAction)), pr.Compose(pr.Third, hex(4)))
 	unicode8 = pr.WithAction(pr.And(backslash, upperU, pr.WithAction(pr.N(pr.HexDigit, 8), pr.ConcatAction)), pr.Compose(pr.Third, hex(8)))
 	escapeChar = pr.Or(lowerT, lowerB, lowerN, lowerR, lowerF, doubleQuote, singleQuote, backslash)
Updated by Patrick Logan

File snippet.go Modified

  • Ignore whitespace
  • Hide word diff
 	unicode4 = pr.WithAction(pr.And(backslash, lowerU, pr.WithAction(pr.N(pr.HexDigit, 4), pr.ConcatAction)), pr.Compose(pr.Third, hex(4)))
 	unicode8 = pr.WithAction(pr.And(backslash, upperU, pr.WithAction(pr.N(pr.HexDigit, 8), pr.ConcatAction)), pr.Compose(pr.Third, hex(8)))
 	escapeChar = pr.Or(lowerT, lowerB, lowerN, lowerR, lowerF, doubleQuote, singleQuote, backslash)
+	escaped = pr.WithAction(pr.And(backslash, escapeChar), pr.Compose(pr.Second, decodeEscape))
Created by Patrick Logan

File snippet.go Added

  • Ignore whitespace
  • Hide word diff
+	unicode4 = pr.WithAction(pr.And(backslash, lowerU, pr.WithAction(pr.N(pr.HexDigit, 4), pr.ConcatAction)), pr.Compose(pr.Third, hex(4)))
+	unicode8 = pr.WithAction(pr.And(backslash, upperU, pr.WithAction(pr.N(pr.HexDigit, 8), pr.ConcatAction)), pr.Compose(pr.Third, hex(8)))
+	escapeChar = pr.Or(lowerT, lowerB, lowerN, lowerR, lowerF, doubleQuote, singleQuote, backslash)
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.