grammar::me::util(n)
β¨ grammar::me::util β the manual bestie π
okay so this is grammar::me::util, from the Tcllib manual pages (that's the collection it lives in, iykyk) π
πΈ NAME πΈ
grammar::me::util β AST utilities β¨ (yes that's the whole name, short and slay)
π¦ SYNOPSIS π¦
package require Tcl 8.5 9
package require grammar::me::util ?0.2?
::grammar::me::util::ast2tree ast tree ?root?
::grammar::me::util::ast2etree ast mcmd tree ?root?
mcmd lc location
mcmd tok from ?to?
::grammar::me::util::tree2ast tree ?root?
likeβ¦ look at her go π
π DESCRIPTION π
This package is literally a whole little squad of utility commands whose entire job is converting between the various representations of abstract syntax trees β exactly as specified in the document grammar::me_ast. no cap, that's the gig π
π§ ::grammar::me::util::ast2tree ast tree ?root?
This one takes an ast and flips it from value representation into object representation. Every single node in the ast gets converted into a node of this tree, and the root of the AST becomes a child of the node root. If you don't say which node explicitly, it just uses the root of the tree. π«
bestie, heads up: the existing content of tree is not touched β not removed, not changed, nothing. the one exception is the specified root node, which will gain a new child. that's it, that's the only glow-up happening. π«Ά
π ::grammar::me::util::ast2etree ast mcmd tree ?root?
This command is like ::grammar::me::util::ast2tree, except the result comes out in the extended object representation of the input AST. the extra info? it comes from the command prefix mcmd. π₯
mcmd has to understand two methods β lc and tok β with the exact semantics below:
β mcmd lc location
Takes the location of a token, given as an offset in the input stream, and returns a 2-element list containing the associated line number and column index, in that order. π
πΈ mcmd tok from ?to?
Takes one or two locations, from and to, as offsets in the input stream, and returns a Tcl list containing the specified part of the input stream. Both locations are inclusive! π If to isn't specified, it defaults to the value of from.
Each element of the returned list is itself a list containing the token, its associated lexeme, the line number, and the column index β in that order. periodt. β¨
Both the ensemble command ::grammar::me::tcl provided by the package grammar::me::tcl, and the objects command created by the package ::grammar::me::cpu, fit the above specification. so you already know some icons are out here matching this energy π
π ::grammar::me::util::tree2ast tree ?root?
This one converts an ast in (extended) object representation back into a value, and returns it. π¦
- If a root node is specified β the AST gets generated from that node downward.
- Otherwise β the root of the tree object is the starting point.
either way she's serving π
π BUGS, IDEAS, FEEDBACK π
ngl, this document β and the package it describes β will undoubtedly contain bugs and other problems. π please report them in the category grammar_me of the Tcllib Trackers at:
http://core.tcl.tk/tcllib/reportlist
Also please report any ideas for enhancements you may have for either the package and/or the documentation. we love ideas, fr fr π«Ά
When proposing code changes, please provide unified diffs, i.e. the output of diff -u.
Note further that attachments are strongly preferred over inlined patches. You can attach stuff by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. it's giving "do it right the first time" π
π KEYWORDS π
abstract syntax tree, syntax tree, tree π³
π CATEGORY π
Grammars and finite automata β
π COPYRIGHT π
Copyright (c) 2005 Andreas Kupries <andreas_kupries@users.sourceforge.net>
and that's the whole page bestie!! this one is from tcllib, version 0.2, and it's the grammar::me::util(n) manual β go forth and convert those trees, you absolute icon ππβ¨
π¦ where this page comes from
- fedora 43: tcllib 2.0-3.fc43 Β· TCL
- fedora 44: tcllib 2.0-4.fc44 Β· TCL
- nixos 26.05: tcllib 2.0
- nixpkgs unstable: tcllib 2.0
- Copyright (c) 2005 Andreas Kupries <andreas_kupries@users\&.sourceforge\&.net>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms