The xmq
library.
Grammars and transforms that xmq downloads on demand from libxmq.org. Parse with ixml:name, the stylesheet with the same name is then applied to clean up the parse. Transform with xsl:name.
xmq ixml:data/csv table.csv to-json
xmq list-library
conf
conf/crontabParse crontab.ixmlv1a
Parse with the grammar:
xmq ixml:conf/crontab input
conf/nginxParse nginx config files.ixmlxslv1a
conf/nginx.xslqv1a
Cleanup after ixml parse of nginx. by Fredrik Öhrström (c) 2026 spdx: MIT
Versions: v1 v1a
Parse with the grammar, then the stylesheet is applied to the parse:
xmq ixml:conf/nginx input
conf/nixParse the declarative Nix configuration subset.ixmlxslv1a
conf/nix.ixmlv1a
Parse the declarative Nix configuration subset. Fredrik Öhrström (c) 2026 spdx: MIT
Versions: v1 v1a
conf/nix.xslqv1a
Cleanup after ixml parse of nix. Fredrik Öhrström (c) 2026 spdx: MIT
Versions: v1 v1a
Parse with the grammar, then the stylesheet is applied to the parse:
xmq ixml:conf/nix input
conf/to-nginxWrite nginx configuration from xmq source.xslv1a
conf/to-nginx.xslqv1a
Write nginx configuration from xmq source. Fredrik Öhrström (c) 2026 spdx: MIT
Versions: v1 v1a
Transform with the stylesheet:
xmq input.xml xsl:conf/to-nginx
conf/to-nixWrite nix configuration from xmq source.xslv1a
conf/to-nix.xslqv1a
Write nix configuration from xmq source. Fredrik Öhrström (c) 2026 spdx: MIT
Versions: v1 v1a
Transform with the stylesheet:
xmq input.xml xsl:conf/to-nix
core
core/ixmlThe ixml grammar for ixml, from the ixml specification.ixmlv1a
Parse with the grammar:
xmq ixml:core/ixml input
core/ixml2htmlRender an ixml grammar as html, from the ixml specification.ixmlv1b
core/ixml2html.ixmlv1b
Render an ixml grammar as html, from the ixml specification. Extended with the xmq ixml extensions: renaming name>alias, rule costs =< and =<<, the controlled ambiguity mark *rule and negative lookahead !factor. The characters < and & are escaped.
Versions: v1 v1a v1b
Parse with the grammar:
xmq ixml:core/ixml2html input
core/ixmlnotcostThe ixml grammar for ixml with the xmq extensions.ixmlv1a
core/ixmlnotcost.ixmlv1a
The ixml grammar for ixml with the xmq extensions. The extensions are the negative lookahead !factor, the rule costs =< and =<<, renaming name>alias and the controlled ambiguity mark *rule. Comments are kept as comment elements, so that they can be deleted, eg to compare two versions of a grammar ignoring changes in the comments: xmq ixml:core/ixmlnotcost grammar.ixml delete //comment to-xmq Based on the ixml grammar for ixml from the ixml specification.
Versions: v1 v1a
Parse with the grammar:
xmq ixml:core/ixmlnotcost input
core/xmqThe xmq language in ixml.ixmlxslv2a
core/xmq.ixmlv2a
The xmq language in ixml. by Fredrik Öhrström (c) 2024-2026 spdx: MIT Rewritten with the not operator ! and greedy tokens, so that the grammar has a single parse and works with the LL(*) parser generator. A greedy token ends with !c where c is a rule that matches one character, eg name = ..., -namechar*, !namechar. The parse tree is turned into the xml dom of the xmq document by xmq.xslq: xmq xmq.ixml input.xmq transform xmq.xslq gives the same document as xmq input.xmq. The tree: xmq { node* } node = element(name) { attributes? children? } | keyvalue(name) { attributes? value } | quote | entity | comment { part+ } | line_comment | doctype { value } | pi(name) { value } | xml attributes { attr(name) { value? }* } children { node* } value = text | quote | entity | compound { (quote | entity)* } Quotes, comments and texts keep their raw content (without the quote chars and comment markers), the incidental indentation is removed by xmq.xslq like the xmq parser does. An entity keeps its name without & and ; eg nbsp or #10.
Versions: v2 v2a
core/xmq.xslqv2a
Build the xmq document from the parse tree of xmq.ixml. by Fredrik Öhrström (c) 2024-2026 spdx: MIT xmq xmq.ixml input.xmq transform xmq.xslq gives the same document as xmq input.xmq. The element and attribute names come from the name attributes, the namespaces from the xmlns declarations, quotes and comments get their incidental indentation removed with the same rules as xmq_trim_quote in xmq.c. What xslt 1.0 cannot create (entity references, the doctype, embedded xml, empty texts, unused namespace declarations, undeclared prefixes) is output as marker elements in the namespace https://libxmq.org/xmq/markers that xmq replaces after the transform, see xmq_replace_transform_markers.
Versions: v2 v2a
Parse with the grammar, then the stylesheet is applied to the parse:
xmq ixml:core/xmq input
data
data/csvCreate a table/tr/td from a csv file (comma separated values).ixmlv1a
data/csv.ixmlv1a
Create a table/tr/td from a csv file (comma separated values). by Fredrik Öhrström spdx: CC0-1.0
Versions: v1 v1a
Parse with the grammar:
xmq ixml:data/csv input
data/scsvCreate a table/tr/td from a scsv file (semicolon separated values).ixmlv1a
data/scsv.ixmlv1a
Create a table/tr/td from a scsv file (semicolon separated values).
Versions: v1 v1a
Parse with the grammar:
xmq ixml:data/scsv input
data/table-to-webRender a table/tr/td document (eg from ixml:data/csv) as a web page.xslv1a
data/table-to-web.xslqv1a
Render a table/tr/td document (eg from ixml:data/csv) as a web page. by Fredrik Öhrström spdx: CC0-1.0
Versions: v1 v1a
Transform with the stylesheet:
xmq input.xml xsl:data/table-to-web
data/tsvCreate a table/tr/td from a file with lines containing tab separated values.ixmlv1a
data/tsv.ixmlv1a
Create a table/tr/td from a file with lines containing tab separated values.
Versions: v1 v1a
Parse with the grammar:
xmq ixml:data/tsv input
lang
lang/cA C grammar written in IXML.ixmlv1a
lang/c.ixmlv1a
A C grammar written in IXML. Copyright (c) 2024-2026 Fredrik Öhrström libxmq (spdx: MIT) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. The grammar is written for the LL(*) parser generator (xmqj generate-parser) as well as the ixml engine: alternatives that share a long prefix are left factored and the dangling else is bound with !kw_else, so that most decisions need a short lookahead. Lists are flat, one element per item. In general we place whitespace ws at the end of each token. Except for the first rule, where we need to accept leading white space. No rule may start with ws, otherwise whitespace can be split ambiguously. The grammar parses the output from the C preprocessor, e.g. gcc -E foo.c The line markers (# 12 "foo.h" 1 3 4) are treated as whitespace. Tokens use the not operator ! to implement maximal munch, e.g. an IDENTIFIER cannot be followed by another identifier character (!idchar) and the token + cannot be followed by + or =. Keywords cannot be identifiers (!keyword). C is not context free, since x * y; is either a declaration or an expression depending on whether x is a typedef name. Some heuristics are used to reduce such ambiguities: - Declaration specifiers can contain at most one typedef name (type_identifier). - A parenthesized declarator must start with a pointer and be followed by a function or array suffix, e.g. (*fp)(int). - A cast to a lone typedef name, (T)x, cannot be followed by + - * & since (x)+1 is then parsed as an expression. A function call has a cost so (T)(x) is a cast and not a call of (T). - sizeof(T) with a lone typedef name is parsed as sizeof of an expression. - An expression statement has a cost, so T *p; in a block is a declaration. - The dangling else binds to the closest if, using !kw_else.
Versions: v1 v1a
Parse with the grammar:
xmq ixml:lang/c input
lang/javaA Java 17 grammar written in IXML.ixmlxslv0g
lang/java.ixmlv0g
A Java 17 grammar written in IXML. Copyright (c) 2026 Fredrik Öhrström libxmq (spdx: MIT) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. The grammar parses Java 17 source files, which are UTF-8. The tree has the contents of the code: names, literals, operators, comments and the structure. Whitespace and punctuation are dropped. The grammar is written for the LL(*) parser generator (xmqj generate-parser) as well as the ixml engine, in the style of library/lang/c.ixml: - Whitespace and comments (ws) are placed at the end of each token, except in the first rule, which accepts leading white space. No rule may start with ws, otherwise whitespace can be split ambiguously. A comment on the line of the token is a comment, a comment on the following lines is a leading_comment, which java.xslq moves to the declaration or statement that follows it. - Tokens use the not operator ! to implement maximal munch, e.g. an IDENTIFIER cannot be followed by another identifier character (!idchar) and the token + cannot be followed by + or =. Keywords cannot be identifiers (!keyword). The contextual keywords (var, yield, record, sealed, permits) are identifiers, matched as keywords only where the syntax needs them. - > is always a single token, so that List<List<String>> closes two type argument lists. The shift operators >> and >>> are > tokens without whitespace between them. The assignments >>= and >>>= are tokens. - Unicode escapes (A) are only recognized inside char, string and text block literals. - Literals keep their source text without the quotes, escapes are not translated, e.g. "a\n" is STRING_LITERAL = a\n The tree, eg for public static <T> List<T>[] f(final int x) throws E { ... } method(name = f) { modifier = public modifier = static type_parameters { type_parameter(name = T) } type { name = List type_arguments { type { name = T } } dim } parameter(name = x) { modifier = final type { primitive = int } } throws { type { name = E } } block } - Declared names are attributes: class(name = A), variable(name = x), ... - A type has a primitive (int) or a dotted name (java.util.List), then its type_arguments, and a dim for every []. A name is split only where type arguments or annotations come between its parts: Outer<String>.Inner is type { name = Outer type_arguments {...} name = Inner } - wildcard { extends {...} } or wildcard { super {...} } for ? extends T. - Annotations and modifiers are kept in source order. - void, varargs, static (of an initializer) and dim are empty elements. - A comment keeps its text without // or /* */, eg comment = ' the x'. After java.xslq the comments on their own lines before a declaration or statement are its first children, eg the javadoc of a method, the comments before a closing brace are the last children of the block, and a comment on the line of a token is after the element of the token. The grammar accepts more than Java in a few places: an expression statement can be any primary (a; is accepted, Java requires a call, x++ or an assignment) and the left side of an assignment can be any primary (1 = x;). Not supported: annotation type declarations (@interface), annotations on types (eg List<@NonNull String>, annotations before a type are modifiers), method references on a generic type (List<String>::size), module-info.java and the Java 21 features (record patterns, patterns in switch).
Versions: v0 v0a v0b v0c v0d v0e v0f v0g
lang/java.xslqv0g
Cleanup after the ixml parse of Java with java.ixml, version v0g as the grammar. Fredrik Öhrström (c) 2026 spdx: MIT The grammar is written for the generated LL(*) parser, so its expressions have an element for every precedence level they pass and the method calls, field and array accesses are chains of selectors on a primary. This stylesheet: - removes the levels without an operator, eg assignment { conditional_expression { logical_or { postfix { name = x } } } } is name = x, and names a level with an operator after the operator, eg additive for + and -, - conditional_expression with ? : is conditional and a level with instanceof is instanceof, - a primary (or postfix) with a selector is method_call, field_access, array_access, method_reference, new (outer.new), this (Outer.this), super (Outer.super) or class_literal (a.b.class), - a chain of names is a dotted name, a.b.c is name = a.b.c, and a method call on it has the dotted name: a.b.c(x) is method_call(name = a.b.c) { arguments }. - a leading comment (on its own line) is moved to the declaration or statement that follows it, or to the end of the block before a closing brace, and the comments of a token with text, eg a name, are after its element. xmq ixml:lang/java Foo.java (uses this cleanup automatically) xmq library/lang/java.ixml Foo.java transform library/lang/java.xslq
Versions: v0 v0e v0f v0g
Parse with the grammar, then the stylesheet is applied to the parse:
xmq ixml:lang/java input
meas
meas/metarA grammar for parsing METAR weather reports.ixmlv1c
meas/metar.ixmlv1c
A grammar for parsing METAR weather reports. Public Domain LLM-generated code (spdx: CC0) Codes are kept, and a sibling -info element explains them in plain words. Numbers are normalized: leading zeros are removed, M becomes a minus sign, cloud bases and vertical visibility are given in feet and inHg pressure gets its decimal point. Example reports: METAR LBBG 041600Z 12012MPS 090V150 1400 R04/P1500N R22/P1500U +SN BKN022 OVC050 M04/M07 Q1020 NOSIG= METAR EFJY 201050Z AUTO 16007KT 9999 -SHRA OVC060CB 15/09 Q1017 Not supported yet: runway state groups like 8849//91, wind shear groups and the time groups (FM, TL, AT) after a trend.
Versions: v1 v1a v1b v1c
Parse with the grammar:
xmq ixml:meas/metar input
meas/metar-to-htmlRender a METAR report, parsed with metar.ixml, as a web page:xslv1b
meas/metar-to-html.xslqv1b
Render a METAR report, parsed with metar.ixml, as a web page: xmq ixml:meas/metar metar.inp xsl:meas/metar-to-html to-html > metar.html A blue header shows the station, the time, the flight category (VFR, MVFR, IFR, LIFR) and the temperature, dew point, pressure and visibility. The wind is drawn on a compass with a bezel and a compass rose, the arrow flies with the wind from the direction it blows from, the variation is drawn as a wedge. The hub shows the speed, colored by its strength, and the Beaufort force is printed below. Every weather group gets an icon on a sky tile with cloud, sun, rain, snow, ice, lightning and fog. The cloud layers are drawn as a cross section of the sky at their altitudes, with as many clouds as the layer has oktas, cumulonimbus and towering cumulus as towers, the precipitation falling from the lowest layer and the vertical visibility as a hatched fog. Every layer is labeled with its okta symbol. Everything is also printed in words in the table below. The groups after a trend (BECMG, TEMPO) are the forecast, they are not drawn but printed with the trend.
Versions: v1 v1a v1b
Transform with the stylesheet:
xmq input.xml xsl:meas/metar-to-html
meas/tafA grammar for parsing TAF terminal aerodrome forecasts.ixmlv1b
meas/taf.ixmlv1b
A grammar for parsing TAF terminal aerodrome forecasts. Public Domain LLM-generated code (spdx: CC0) The forecast is split into the base forecast, the conditions expected for the whole validity period, followed by a change element for every change group, FM (from), BECMG (becoming), TEMPO (temporarily), INTER (intermittently) and PROB30/PROB40, that holds the conditions it changes. The groups may be written on several lines. Codes are kept, and a sibling -info element explains them in plain words. Numbers are normalized like in metar.ixml: leading zeros are removed, M becomes a minus sign and cloud bases are given in feet. Example forecasts: TAF EGLL 201059Z 2012/2118 24012KT 9999 SCT030 TEMPO 2012/2016 4000 SHRA BKN014 BECMG 2020/2023 VRB03KT PROB30 2103/2108 0800 FG BKN002 TAF AMD KJFK 201745Z 2018/2124 24015G25KT P6SM SCT050 FM202200 30010KT P6SM FEW250 TX25/2019Z TN14/2110Z Not supported: the old validity periods with 6 digits (eg 051212), the military icing and turbulence groups and the QNH groups.
Versions: v1 v1a v1b
Parse with the grammar:
xmq ixml:meas/taf input
meas/taf-to-htmlRender a TAF forecast, parsed with taf.ixml, as a web page:xslv1a
meas/taf-to-html.xslqv1a
Render a TAF forecast, parsed with taf.ixml, as a web page: xmq ixml:meas/taf taf.inp xsl:meas/taf-to-html to-html > taf.html A blue header shows the station, the issue time, the validity period, the flight category (VFR, MVFR, IFR, LIFR) of the base forecast and the maximum and minimum temperatures. A timeline spans the validity period. The prevailing conditions, the base forecast and the FM groups, are drawn on the first row, every BECMG, TEMPO, INTER and PROB group gets a row of its own. The bars are colored by the flight category of their conditions, a BECMG bar fades into the new conditions that then last until the next FM group. Below every period gets a card with a weather icon, the wind arrow, the visibility, the weather and the cloud layers with their okta symbols.
Versions: v1 v1a
Transform with the stylesheet:
xmq input.xml xsl:meas/taf-to-html
misc
misc/testmeterParse a wireless mbus telegram from a test meter, the example telegram follows.ixmlv1a
misc/testmeter.ixmlv1a
Parse a wireless mbus telegram from a test meter, the example telegram follows.
Versions: v1 v1a
Parse with the grammar:
xmq ixml:misc/testmeter input
xmq-utils
xmq-utils/parse-traceParse the ixml trace lines printed by xmq --trace (used by the OpenMike scripts).ixmlv1a
xmq-utils/parse-trace.ixmlv1a
Parse the ixml trace lines printed by xmq --trace (used by the OpenMike scripts).
Versions: v1 v1a
Parse with the grammar:
xmq ixml:xmq-utils/parse-trace input
xmq-utils/render-trace-to-htmlRender an ixml trace, recorded with xmq --traceixml=trace.xmq (or xmqj), as a web page:xslv1a
xmq-utils/render-trace-to-html.xslqv1a
Render an ixml trace, recorded with xmq --traceixml=trace.xmq (or xmqj), as a web page: xmq trace.xmq transform render-trace-to-html.xslq to-html > trace.html Every Earley item is a row: a cell spans the input it matched, below the tokens, and the rule with the dot is to the right. The items used in the tree are marked. Then the tree building: the tree is built top-down from the start rule, and every row adds a node. A column shows the latest node added over it, so a new node replaces its parent over the input it matched. When a choice is made by cost the alternatives are all built, the ones not chosen are struck out, and the last row shows the chosen tree.
Versions: v1 v1a
Transform with the stylesheet:
xmq input.xml xsl:xmq-utils/render-trace-to-html
xmq-utils/render-trace-to-terminalRender an ixml trace, recorded with xmq --traceixml=parse.xmq (or xmqj), in the terminalxslv1a
xmq-utils/render-trace-to-terminal.xslqv1a
Render an ixml trace, recorded with xmq --traceixml=parse.xmq (or xmqj), in the terminal with ansi colors: xmq parse.xmq transform library/xmq-utils/render-trace-to-terminal.xslq to-text xmq parse.xmq transform library/xmq-utils/render-trace-to-terminal.xslq to-text | less -RS Like render-trace-to-html.xslq: every Earley item is a row, a cell spans the input it matched below the tokens, and the rule with the dot is to the right. The items used in the tree are dark green. Then the tree building: every row adds a node, top-down, and a column shows the latest node added over it. The new node is dark green, its parent orange, the nodes not chosen by cost are struck out, and the last row is the chosen tree.
Versions: v1 v1a
Transform with the stylesheet:
xmq input.xml xsl:xmq-utils/render-trace-to-terminal
xmq-utils/render-trace-to-texRender an ixml trace, recorded with xmq --traceixml=trace.xmq (or xmqj), as a LaTeX document:xslv1a
xmq-utils/render-trace-to-tex.xslqv1a
Render an ixml trace, recorded with xmq --traceixml=trace.xmq (or xmqj), as a LaTeX document: xmq trace.xmq transform render-trace-to-tex.xslq to-text > trace.tex pdflatex trace.tex; pdflatex trace.tex (longtable needs two runs to line up the columns) Like render-trace-to-html.xslq: every Earley item is a row, a cell spans the input it matched below the tokens, and the rule with the dot is in the last column. The items used in the tree are dark green. Then the tree building: every row adds a node, top-down, and a column shows the latest node added over it. The new node is dark green and its parent orange. When a choice is made by cost the alternatives are all built, the ones not chosen are grey, and the last row shows the chosen tree.
Versions: v1 v1a
Transform with the stylesheet:
xmq input.xml xsl:xmq-utils/render-trace-to-tex
xmq-utils/xmqcliThe xmq command line.ixmlv2a
xmq-utils/xmqcli.ixmlv2a
The xmq command line. Fredrik Öhrström (c) 2026 spdx: MIT The command line arguments (argv) are joined into a single line, which is parsed with this grammar. The line starts with xmq, then every argument follows separated by a single space. An argument that is empty or contains whitespace, quotes or backslashes is written inside double quotes, where " and \ are escaped with a backslash. For an option with a value, --name=value, only the value is quoted, eg --shell="echo \"${.}\"". Example: xmq --trim=none index.html delete //script select -c "//a[@x=1]" to-html gives: xmq { option(name=trim value=none) file=index.html command(name=delete){arg='//script'} command(name=select){option(name=compact) arg='//a[@x=1]'} command(name=to-html) } An argument never starts with a minus, to give an argument starting with a minus, use -- before it: select -x -- -x
Versions: v2 v2a
Parse with the grammar:
xmq ixml:xmq-utils/xmqcli input