gop icon indicating copy to clipboard operation
gop copied to clipboard

Go+ domain-specific text literal

Open xushiwei opened this issue 9 months ago • 3 comments

Proposal

In markdown:

```domainTag
...
...
```

In Go+:

domainTag`
...
...
`

Background

See https://github.com/goplus/gop/issues/1770

Workarounds

none

xushiwei avatar Mar 01 '25 09:03 xushiwei

examples:

  • tpl
cl := tpl`expr = INT % ("+" | "-")`!
echo cl.parseExpr("1+2-3", nil)
  • json/xml/csv
echo json`{"a":1, "b":2}`
echo xml`<a>1</a>`
echo csv`a,b`
  • html
import "golang.org/x/net/html"

echo html`<html><body><h1>hello</h1></body></html>`
  • regexp, regexposix (POSIX)
re := regexp`^[a-z]+\[[0-9]+\]$`!
echo re.matchString("adam[23]")

xushiwei avatar Mar 05 '25 00:03 xushiwei

https://github.com/goplus/gop/blob/main/doc/domian-text-lit.md

xushiwei avatar Apr 07 '25 17:04 xushiwei

domainTextLit with args:

  • https://github.com/goplus/gop/pull/2302
  • https://github.com/goplus/gop/pull/2303
// A DomainTextLit node represents a domain-specific text literal.
// https://github.com/goplus/gop/issues/2143
//
//	domainTag`...`
//	domainTag`> arg1, arg2, ...
//	  ...
//	`

xushiwei avatar Apr 23 '25 15:04 xushiwei

@niupilot Please add documentation related to domain-specific text literal to the quick start.

xushiwei avatar Oct 11 '25 02:10 xushiwei

Documentation Added Successfully! ✅

I've added comprehensive documentation for domain-specific text literals to the quick start guide.

What was added:

  • New section: "Domain-Specific Text Literals" in the quick start guide
  • Syntax examples: Both basic and parameterized domain text literal syntax
  • Built-in formats: Documented tpl, json, xml, csv, html, and regexp with code examples
  • How it works: Explained the function call mechanism
  • Extensibility: Information on creating custom domain text formats
  • Table of contents: Updated to include the new section

Pull Request

Created PR #2460 with all the changes: https://github.com/goplus/xgo/pull/2460

The documentation is now ready for review and provides clear, practical examples for users to understand and use domain-specific text literals in XGo.


Job Run | Branch: codeagent/claude/issue-2143-1760151236 | PR #2460

niupilot[bot] avatar Oct 11 '25 02:10 niupilot[bot]