Atom parses an Atom from given string.
(s string)
| 746 | |
| 747 | // Atom parses an Atom from given string. |
| 748 | func Atom(s string) (ast.Atom, error) { |
| 749 | term, err := Term(s) |
| 750 | if err != nil { |
| 751 | return ast.Atom{}, err |
| 752 | } |
| 753 | atom, ok := term.(ast.Atom) |
| 754 | if !ok { |
| 755 | return ast.Atom{}, fmt.Errorf("not an atom: %v %T", term, term) |
| 756 | } |
| 757 | return atom, nil |
| 758 | } |
| 759 | |
| 760 | func nameAtom(name string) ast.Atom { |
| 761 | return ast.Atom{Predicate: ast.PredicateSym{Symbol: "name", Arity: 1}, Args: []ast.BaseTerm{ast.String(name)}} |