Skip to content

foresight_tokens ​

foresight_tokens, lexer of the gnuplot-like command language.

A line is split into statements at ; and cut at # (both outside quotes); a statement into tokens: words, quoted strings (single quotes literal, double quotes with \t for a tab and \ taking the next character literally, so \" and \\, as gnuplot), commas and bracketed ranges [a:b]. Each token remembers where it lies in the statement, so that a plot item can be quoted as written. Inside parentheses a word goes on across blanks and commas: ($2 * 1e3) and atan2($2, $1) are single words; quotes inside a word keep their content, blanks included, and a quoted string followed by : starts a word: 1:"the res" and "it":"res" are using specifications.

Source: src/lib/foresight_tokens.F90

Contents ​

Variables ​

NameTypeAttributesDescription
TOKEN_WORDinteger(kind=I4P)parameterBare word: keyword, number, column spec.
TOKEN_STRINGinteger(kind=I4P)parameterQuoted string, quotes removed.
TOKEN_COMMAinteger(kind=I4P)parameterComma.
TOKEN_RANGEinteger(kind=I4P)parameterBracketed range, brackets removed.

Derived Types ​

token_object ​

Token.

Components ​

NameTypeAttributesDescription
kindinteger(kind=I4P)Token kind.
textcharacter(len=:)allocatableToken text.
quotecharacter(len=1)Quote of a string token, blank for others.
firstinteger(kind=I4P)First character in the statement, quotes or brackets included.
lastinteger(kind=I4P)Last character in the statement.

Subroutines ​

split_statements ​

Split line at ; outside quotes, dropping the # comment; blank statements are skipped.

fortran
subroutine split_statements(line, statements)

Arguments

NameTypeIntentAttributesDescription
linecharacter(len=*)inSource line.
statementstype(token_object)outallocatableStatements (kind word).

Call graph

tokenize ​

Split statement into tokens.

Attributes: pure

fortran
subroutine tokenize(statement, tokens, iostat, iomsg)

Arguments

NameTypeIntentAttributesDescription
statementcharacter(len=*)inStatement.
tokenstype(token_object)outallocatableTokens.
iostatinteger(kind=I4P)out0, or 1 on a lexical error.
iomsgcharacter(len=:)outallocatableError message.

Call graph