The chemical-compounds Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The chemical-compounds Reference Manual

This is the chemical-compounds Reference Manual, version 1.0.1, generated automatically by Declt version 2.4 "Will Decker" on Wed Jun 20 10:55:07 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

chemical-compounds -- parsing, pretty-printing, and formula weights of
chemical compounds.

Copyright 2004 Peter Scott
Released under the LLGPL (see
http://opensource.franz.com/preamble.html).

Introduction
============

Sometimes you want to be able to parse chemical formulas in a
normal, user-friendly syntax. For example, water is usually written
"H2O". This representation is good for users, but for Lisp code, you
need a different representation. In chemical-compounds, H2O would be
represented as ((H 2) O).

A more complicated molecule is glucose, C6H12O6. This is
((C 6) (H 12) (O 6)) in our internal representation. You may have
noticed that "C6H12O6" is ugly and hard to read, due to the clunky way
that plain text deals with the subscripts. Therefore, in the format
used by chemical-compounds, glucose is "C6 H12 O6", with spaces.

Some chemical formulas parenthesize parts of the compound and add a
subscript. The formula "(C O2)4 H2" would be parsed as
(((C (O 2)) 4) (H 2)).


Functions
=========

The :compounds package exports four functions:


(pprint-compound compound stream): takes a compound in the Lisp
internal representation and prints it to a stream in the pretty
syntax.

Example:

(with-output-to-string (s) (pprint-compound '((H 2) O) s))
=> "H2 O"

-----------

(parse-compound string): parse a compound string and return the
internal Lisp representation of it.

Examples:

(parse-compound "C6 H12 O6") => ((C 6) (H 12) (O 6))
(parse-compound "(C O2)4 H2") => (((C (O 2)) 4) (H 2))

-----------

(formula-weight compound): Calculate the number of grams per mole of a
compound.

Examples:

(formula-weight '((C 6) (H 12) (O 6))) => 180.15768
(formula-weight (parse-compound "C6 H12 O6")) => 180.15768

-----------

(get-compound compound): Return a compound designator given either a
compound designator or a string in compound syntax.

Examples:

(get-compound "C6 H12 O6") => ((C 6) (H 12) (O 6))
(get-compound '((C 6) (H 12) (O 6))) => ((C 6) (H 12) (O 6))

-----------


If you have any questions, please ask them on the chemboy-devel mailing list
at .

Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 chemical-compounds

Author

Peter Scott

License

LLGPL

Version

1.0.1

Dependency

periodic-table

Source

chemical-compounds.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 chemical-compounds.asd

Location

chemical-compounds.asd

Systems

chemical-compounds (system)

Packages

chemical-compounds-system


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.2 chemical-compounds/parsing.lisp

Parent

chemical-compounds (system)

Location

parsing.lisp

Packages

compound-parsing

Exported Definitions

parse-compound (function)

Internal Definitions

Previous: , Up: Lisp files   [Contents][Index]

3.1.3 chemical-compounds/compounds.lisp

Dependency

parsing.lisp (file)

Parent

chemical-compounds (system)

Location

compounds.lisp

Packages

compounds

Exported Definitions
Internal Definitions

element-number-pair-p (function)


Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

4.1 chemical-compounds-system

Source

chemical-compounds.asd

Use List

Next: , Previous: , Up: Packages   [Contents][Index]

4.2 compound-parsing

Source

parsing.lisp (file)

Use List

common-lisp

Exported Definitions

parse-compound (function)

Internal Definitions

Previous: , Up: Packages   [Contents][Index]

4.3 compounds

Source

compounds.lisp (file)

Use List
Exported Definitions
Internal Definitions

element-number-pair-p (function)


Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Functions

Function: formula-weight COMPOUND

The number of grams per mole of a compound

Package

compounds

Source

compounds.lisp (file)

Function: get-compound COMPOUND

Return a compound designator given either a compound designator or a string in compound syntax

Package

compounds

Source

compounds.lisp (file)

Function: parse-compound STRING &optional INDEX END &aux COMPONENT-LIST COMPONENT-LIST-STACK ELEMENT-SYMBOL NUMBER C
Package

compound-parsing

Source

parsing.lisp (file)

Function: parse-compound STRING

Parse a compound string, such as C6 H12 O6

Package

compounds

Source

compounds.lisp (file)

Function: pprint-compound COMPOUND &key STREAM PARENS

Pretty print a compound, putting parens around it if ‘parens’ is t. This is so ugly that I’ve come to despise it, but it works. Don’t touch it unless you want it to shatter into a million little pieces.

Package

compounds

Source

compounds.lisp (file)


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Special variables

Special Variable: *meta-debug*

Should META output debugging information?

Package

compound-parsing

Source

parsing.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Macros

Macro: defmeta NAME OTHER-ARGS &body BODY
Package

compound-parsing

Source

parsing.lisp (file)

Macro: match X
Package

compound-parsing

Source

parsing.lisp (file)

Macro: match-type X V
Package

compound-parsing

Source

parsing.lisp (file)

Macro: matchit X
Package

compound-parsing

Source

parsing.lisp (file)

Macro: meta-labels FUNCTIONS &body BODY
Package

compound-parsing

Source

parsing.lisp (file)

Macro: with-string-accumulation STRINGS &body BODY

Given a list of symbols, create character output streams bound to the symbols given in ‘strings’ with -STREAM appended, execute ‘body’ in this environment, and SETF all the symbol-values of the symbols in ‘strings’ to the values of their respective string output streams.

It also defines a local function FORCE-STRING-ACCUMULATION which will do the SETFing when it is called. It is called automatically at the end of the block, but you can call it earlier, as many times as you like. It clears the string streams, so be careful when using it.

The utility of this macro may not be readily apparent, but is can be very handy in META parsers which need to accumulate characters into strings.

Package

compound-parsing

Source

parsing.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.3 Functions

Function: compileit X
Package

compound-parsing

Source

parsing.lisp (file)

Function: copy-meta INSTANCE
Package

compound-parsing

Source

parsing.lisp (file)

Function: ctoi D
Package

compound-parsing

Source

parsing.lisp (file)

Function: element-number-pair-p COMPOUND

Return t if ‘compound’ is a pair of an element and a number of that element, such as (C 6)

Package

compounds

Source

compounds.lisp (file)

Function: end-of-string-p STRING INDEX

Is index above the maximum index allowed for a given string?

Package

compound-parsing

Source

parsing.lisp (file)

Function: make-meta &key (CHAR CHAR) (FORM FORM)
Package

compound-parsing

Source

parsing.lisp (file)

Function: meta-char INSTANCE
Function: (setf meta-char) VALUE INSTANCE
Package

compound-parsing

Source

parsing.lisp (file)

Function: meta-form INSTANCE
Function: (setf meta-form) VALUE INSTANCE
Package

compound-parsing

Source

parsing.lisp (file)

Function: meta-p OBJECT
Package

compound-parsing

Source

parsing.lisp (file)

Function: meta-reader S C
Package

compound-parsing

Source

parsing.lisp (file)

Function: parse-int STRING &optional INDEX END &aux S D N
Package

compound-parsing

Source

parsing.lisp (file)

Function: parse-query-string STRING &optional INDEX END &aux AMOUNT UNIT ELEMENT BASE-TRIPLE CONDITIONS C
Package

compound-parsing

Source

parsing.lisp (file)

Function: parse-x-and-y STRING &optional INDEX END &aux VERB NOUN C
Package

compound-parsing

Source

parsing.lisp (file)

Function: strings->element-list ELEMENT NUMBER

Convert an element (which may be a string or a compound designator) and a number given as a string into a proper compound designator.

Package

compound-parsing

Source

parsing.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.4 Structures

Structure: meta ()
Package

compound-parsing

Source

parsing.lisp (file)

Direct superclasses

structure-object (structure)

Direct methods

print-object (method)

Direct slots
Slot: char
Readers

meta-char (function)

Writers

(setf meta-char) (function)

Slot: form
Readers

meta-form (function)

Writers

(setf meta-form) (function)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.5 Types

Type: digit ()
Package

compound-parsing

Source

parsing.lisp (file)

Type: non-rparen-char ()
Package

compound-parsing

Source

parsing.lisp (file)

Type: nonspace-char ()
Package

compound-parsing

Source

parsing.lisp (file)

Type: number-char ()
Package

compound-parsing

Source

parsing.lisp (file)

Type: space-char ()
Package

compound-parsing

Source

parsing.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   C   F   L  
Index Entry  Section

C
chemical-compounds.asd: The chemical-compounds<dot>asd file
chemical-compounds/compounds.lisp: The chemical-compounds/compounds<dot>lisp file
chemical-compounds/parsing.lisp: The chemical-compounds/parsing<dot>lisp file

F
File, Lisp, chemical-compounds.asd: The chemical-compounds<dot>asd file
File, Lisp, chemical-compounds/compounds.lisp: The chemical-compounds/compounds<dot>lisp file
File, Lisp, chemical-compounds/parsing.lisp: The chemical-compounds/parsing<dot>lisp file

L
Lisp File, chemical-compounds.asd: The chemical-compounds<dot>asd file
Lisp File, chemical-compounds/compounds.lisp: The chemical-compounds/compounds<dot>lisp file
Lisp File, chemical-compounds/parsing.lisp: The chemical-compounds/parsing<dot>lisp file

Jump to:   C   F   L  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   (  
C   D   E   F   G   M   P   S   W  
Index Entry  Section

(
(setf meta-char): Internal functions
(setf meta-form): Internal functions

C
compileit: Internal functions
copy-meta: Internal functions
ctoi: Internal functions

D
defmeta: Internal macros

E
element-number-pair-p: Internal functions
end-of-string-p: Internal functions

F
formula-weight: Exported functions
Function, (setf meta-char): Internal functions
Function, (setf meta-form): Internal functions
Function, compileit: Internal functions
Function, copy-meta: Internal functions
Function, ctoi: Internal functions
Function, element-number-pair-p: Internal functions
Function, end-of-string-p: Internal functions
Function, formula-weight: Exported functions
Function, get-compound: Exported functions
Function, make-meta: Internal functions
Function, meta-char: Internal functions
Function, meta-form: Internal functions
Function, meta-p: Internal functions
Function, meta-reader: Internal functions
Function, parse-compound: Exported functions
Function, parse-compound: Exported functions
Function, parse-int: Internal functions
Function, parse-query-string: Internal functions
Function, parse-x-and-y: Internal functions
Function, pprint-compound: Exported functions
Function, strings->element-list: Internal functions

G
get-compound: Exported functions

M
Macro, defmeta: Internal macros
Macro, match: Internal macros
Macro, match-type: Internal macros
Macro, matchit: Internal macros
Macro, meta-labels: Internal macros
Macro, with-string-accumulation: Internal macros
make-meta: Internal functions
match: Internal macros
match-type: Internal macros
matchit: Internal macros
meta-char: Internal functions
meta-form: Internal functions
meta-labels: Internal macros
meta-p: Internal functions
meta-reader: Internal functions

P
parse-compound: Exported functions
parse-compound: Exported functions
parse-int: Internal functions
parse-query-string: Internal functions
parse-x-and-y: Internal functions
pprint-compound: Exported functions

S
strings->element-list: Internal functions

W
with-string-accumulation: Internal macros

Jump to:   (  
C   D   E   F   G   M   P   S   W  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *  
C   F   S  
Index Entry  Section

*
*meta-debug*: Internal special variables

C
char: Internal structures

F
form: Internal structures

S
Slot, char: Internal structures
Slot, form: Internal structures
Special Variable, *meta-debug*: Internal special variables

Jump to:   *  
C   F   S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   C   D   M   N   P   S   T  
Index Entry  Section

C
chemical-compounds: The chemical-compounds system
chemical-compounds-system: The chemical-compounds-system package
compound-parsing: The compound-parsing package
compounds: The compounds package

D
digit: Internal types

M
meta: Internal structures

N
non-rparen-char: Internal types
nonspace-char: Internal types
number-char: Internal types

P
Package, chemical-compounds-system: The chemical-compounds-system package
Package, compound-parsing: The compound-parsing package
Package, compounds: The compounds package

S
space-char: Internal types
Structure, meta: Internal structures
System, chemical-compounds: The chemical-compounds system

T
Type, digit: Internal types
Type, non-rparen-char: Internal types
Type, nonspace-char: Internal types
Type, number-char: Internal types
Type, space-char: Internal types

Jump to:   C   D   M   N   P   S   T