Skip to main content

quilt/
meta.rs

1use crate::lang::Arity;
2use crate::prelude::*;
3use crate::qterm::QTerm;
4use crate::term::CmdOrHole;
5use std::borrow::Cow;
6use std::fmt::Debug;
7use std::sync::Arc;
8
9/**************************************************************/
10
11pub const LIFT: &str = "__LIFT__";
12pub const REDUCE: &str = "__REDUCE__";
13pub const EMIT: &str = "__EMIT__";
14pub const TYPE: &str = "__TYPE__";
15pub const NAME: &str = "__NAME__";
16
17/// The body every host's [`MetaLanguage::spawn_str`] shares: refuse a
18/// language no provider backs, then let the host spell the rest.
19///
20/// The refusal is here rather than in generated code so that `wgsl⟨M⟩` is a
21/// diagnostic at expansion time — pointing at the glyph in the `.quilt`
22/// source, where the mistake is — instead of a failure inside an artifact
23/// whose reader has no idea a glyph produced it.
24pub fn spawn_spelling(
25    host: &str,
26    lang: &str,
27    spell: impl FnOnce(&str) -> String,
28) -> Result<String> {
29    if !crate::machine::has_spec(lang) {
30        miette::bail!(
31            "no machine is registered for {lang:?}, so `{lang}⟨M⟩` gives {host} nothing to \
32             spawn; quilt knows: {}",
33            crate::machine::REGISTERED_SPECS.join(", ")
34        );
35    }
36    Ok(spell(lang))
37}
38
39/// The runtime import an expanded file must open with — `use quilt::prelude::*;`
40/// for Rust, `from quilt import *` for Python — together with how to tell that
41/// the author already wrote it by hand.
42///
43/// It exists because expanded code *calls a runtime*: `tb(..)`, `qlift(..)`,
44/// `name(..)` are names that have to be in scope, and until now every author of
45/// a `.quilt` file typed the import that brings them there. See
46/// [`MetaLanguage::prelude`].
47#[derive(Debug, Clone, PartialEq, Eq)]
48pub struct Prelude {
49    /// The text to inject, with no trailing newline. May be several lines.
50    pub text: Cow<'static, str>,
51    /// Substrings whose presence in the *source* means the runtime is already
52    /// imported by hand; any one match suppresses injection. A doubled glob
53    /// import is harmless in Rust and Python, but a doubled *named* import is a
54    /// hard error in TypeScript, so this is not merely tidiness.
55    ///
56    /// They are matched against the source rather than the expansion because a
57    /// ground-stage import is copied through verbatim, and the source is in
58    /// hand before anything is written.
59    pub markers: Vec<Cow<'static, str>>,
60}
61
62impl Prelude {
63    pub fn new(
64        text: impl Into<Cow<'static, str>>,
65        markers: impl IntoIterator<Item = &'static str>,
66    ) -> Self {
67        Prelude {
68            text: text.into(),
69            markers: markers.into_iter().map(Cow::Borrowed).collect(),
70        }
71    }
72
73    /// Whether `src` already imports this runtime, so injecting would duplicate
74    /// it.
75    #[must_use]
76    pub fn present_in(&self, src: &str) -> bool {
77        self.markers.iter().any(|m| src.contains(&**m))
78    }
79}
80
81/// `body` — code generated for `lang` — opened with `prelude`, placed after
82/// whatever has to stay at the top (see [`prelude_offset`]). The injection
83/// [`Multi::prelude_for`](crate::multi::Multi::prelude_for) decides on, issue
84/// #274.
85///
86/// `lang` names the language (any alias) whose line comments make up the
87/// header the prelude goes after; `//` for one the registry does not know.
88/// Needs `parse`, which is what the language registry it asks lives behind.
89#[cfg(feature = "parse")]
90#[must_use]
91pub fn with_prelude(body: &str, prelude: &str, lang: &str) -> String {
92    let line_comment = crate::langs::line_comment(lang).unwrap_or("//");
93    let at = prelude_offset(body, line_comment);
94    let (before, after) = body.split_at(at);
95    if after.is_empty() {
96        format!("{before}{prelude}\n")
97    } else {
98        format!("{before}{prelude}\n\n{after}")
99    }
100}
101
102/// The byte offset in `body` at which a runtime import can be inserted: after
103/// the leading header — blank lines, whole-line comments, a shebang and Rust's
104/// inner attributes — and before the first item.
105///
106/// Not cosmetic. Rust's `//!` doc comments and `#![…]` attributes are *inner*,
107/// and inner means "before any item", so an import written above a file's `//!`
108/// header turns the header itself into a syntax error (`expected outer doc
109/// comment`) — which is what nine of this repo's own examples do. Python and
110/// TypeScript are laxer, but a header is what a reader expects first there too,
111/// and a `#!` shebang is only a shebang on line 1.
112///
113/// A line comment is recognised by `line_comment`, the ground language's own
114/// introducer, so `//!` and `//` both count for Rust and `#`-anything for
115/// Python (its shebang included).
116#[cfg(feature = "parse")]
117fn prelude_offset(body: &str, line_comment: &str) -> usize {
118    let mut at = 0;
119    let mut rest = body;
120    while !rest.is_empty() {
121        let line_end = rest.find('\n').map_or(rest.len(), |i| i + 1);
122        let line = rest[..line_end].trim_end();
123        let take = if line.is_empty() || line.starts_with(line_comment) {
124            line_end
125        } else if line.starts_with("#![") {
126            // An inner attribute, which may wrap across lines: take it whole,
127            // by balancing its brackets. Splitting one is worse than placing
128            // the import above it.
129            match attribute_end(rest) {
130                Some(end) => end,
131                None => break,
132            }
133        } else if at == 0 && line.starts_with("#!") {
134            line_end // a shebang, which is only one on the first line
135        } else {
136            break;
137        };
138        at += take;
139        rest = &rest[take..];
140    }
141    at
142}
143
144/// The byte length of the `#![…]` inner attribute `s` starts with, counting to
145/// the `]` that balances its `[` (so a nested `[..]` inside does not end it) and
146/// through the newline after it. `None` if the brackets never balance.
147#[cfg(feature = "parse")]
148fn attribute_end(s: &str) -> Option<usize> {
149    let mut depth = 0usize;
150    for (i, c) in s.char_indices() {
151        match c {
152            '[' => depth += 1,
153            ']' => {
154                depth -= 1;
155                if depth == 0 {
156                    let after = i + c.len_utf8();
157                    return Some(s[after..].find('\n').map_or(s.len(), |j| after + j + 1));
158                }
159            }
160            _ => {}
161        }
162    }
163    None
164}
165
166/// One element of a quote flattened for a non-`cst` representation (see
167/// [`MetaLanguage::expand_flat`]): the quote's text with its layout commands,
168/// and a hole wherever a ground unquote sits.
169#[derive(Debug, Clone)]
170pub enum Piece {
171    /// Literal text of the quoted code (never containing a layout newline).
172    Text(Box<str>),
173    /// A newline, after which the pushed prefixes are written.
174    NewLine,
175    /// Push an indentation prefix.
176    Push(Box<str>),
177    /// Pop the last prefix.
178    Pop,
179    /// A ground unquote's value: the *expanded* host expression.
180    Hole(Arc<QTerm>),
181}
182
183/// The error a host gives for a representation it does not implement.
184#[must_use]
185pub fn no_repr(repr: crate::qterm::Repr) -> miette::Report {
186    miette!(
187        "this host has no {repr} quotes yet: only `⟨cst⟩` (the default) is implemented \
188         for it — TypeScript has all three"
189    )
190}
191
192#[derive(Debug, Clone, Copy, Default)]
193pub enum OuterKind {
194    #[default]
195    None,
196    Emit,
197    Splice,
198}
199
200pub trait MetaLanguage {
201    fn expand_quote(
202        &self,
203        lang1: &str,
204        tag: &str,
205        i: Index,
206        lang2: &str,
207        qterm: &Arc<QTerm>,
208        cmds: &[CmdOrHole],
209    ) -> Result<Arc<QTerm>>;
210    fn expand_unquote(
211        &self,
212        lang1: &str,
213        tag: &str,
214        i: Index,
215        lang2: &str,
216        qterm: &Arc<QTerm>,
217        cmds: &[CmdOrHole],
218    ) -> Result<Arc<QTerm>>;
219    fn expand_tuple(
220        &self,
221        lang1: &str,
222        tag: &str,
223        qterms: &[Arc<QTerm>],
224        cmds: &[CmdOrHole],
225        arity: Arity, // should we split expand_tuple based on variadic vs not?
226    ) -> Result<Arc<QTerm>>;
227
228    /// Wrap an expanded child of a tuple.
229    /// * `qterm` - the child term to wrap
230    /// * `okind` - an outer kind like splice/emit/none
231    fn wrap_child(&self, qterm: Arc<QTerm>, _okind: OuterKind) -> Result<Arc<QTerm>> {
232        Ok(qterm)
233    }
234
235    /// Wrap an already-[wrapped](Self::wrap_child) splice into a
236    /// comma-separated list (`[↙xs↘]`, `f(↙xs↘)`) so that the elements it
237    /// contributes are separated by `sep` (#293): the builder's
238    /// `sep(..)`/`end_sep()` region around the child.
239    ///
240    /// The default leaves the child alone, for a meta whose builder has no
241    /// such region.
242    fn wrap_separated(&self, qterm: Arc<QTerm>, _sep: &str) -> Result<Arc<QTerm>> {
243        Ok(qterm)
244    }
245
246    /// The ground-tuple tag that introduces a pattern-let (e.g. Rust's
247    /// `let_declaration`), or `None` if this meta-language has no pattern
248    /// matching. A ground tuple with this tag whose binding position holds a
249    /// quote is expanded as `let ↖pattern↗ = value;` (see
250    /// `Expander::expand_pattern_let` and `crate::qmatch`).
251    fn pattern_tag(&self) -> Option<&'static str> {
252        None
253    }
254
255    /// Where the pattern and value sit among the children of a
256    /// [`pattern_tag`](Self::pattern_tag) tuple, as `(pattern_ix, value_ix)`.
257    ///
258    /// The expander used to hardcode this: it scanned for a child tagged
259    /// literally `"="` and took the pattern from `terms[1]`. Both assumptions are
260    /// Rust's, sitting in the language-agnostic core — so a host whose binding
261    /// form uses `:=` or `<-` could not have pattern-lets even after supplying a
262    /// `pattern_tag`, and `let mut ↖p↗ = v` (where `mutable_specifier` shifts the
263    /// pattern off index 1) silently expanded to Rust that does not compile
264    /// (issue #174, finding E3).
265    ///
266    /// `None` means this tuple is not a pattern-let, so the expander treats it as
267    /// an ordinary ground tuple. Implementations will usually delegate to
268    /// [`crate::qmatch::pattern_binding_at`] with their separator token.
269    fn pattern_binding(&self, terms: &[Arc<QTerm>]) -> Option<(usize, usize)> {
270        let _ = terms;
271        None
272    }
273
274    /// Code for a pattern metavariable: the expression spliced where `↙name↘`
275    /// sits inside a pattern quote (e.g. `mvar("name")` for Rust).
276    fn pattern_var(&self, name: &str) -> Result<Arc<QTerm>> {
277        let _ = name;
278        Err(miette!(
279            "this meta-language does not support pattern matching"
280        ))
281    }
282
283    /// The two terms a pattern-let rewrites to: the destructuring binder that
284    /// replaces the pattern quote (e.g. `[a, b]`) and the matching call that
285    /// replaces the initializer (e.g. `qmatch_n(&*<pattern>, &<value>)`).
286    fn pattern_let(
287        &self,
288        names: &[Box<str>],
289        pattern: &Arc<QTerm>,
290        value: &Arc<QTerm>,
291    ) -> Result<(Arc<QTerm>, Arc<QTerm>)> {
292        let _ = (names, pattern, value);
293        Err(miette!(
294            "this meta-language does not support pattern matching"
295        ))
296    }
297
298    /// The spelling `↑` expands to when lifting into the object language
299    /// `target` (e.g. Rust lifting a value into a WGSL term). The homogeneous
300    /// case is `target` == the meta-language's own language; the default
301    /// ignores `target`, preserving that behavior for metas without
302    /// heterogeneous support.
303    #[inline]
304    fn lift_str(&self, target: &str) -> Result<&'static str> {
305        let _ = target;
306        Ok(LIFT)
307    }
308    /// The spelling `↓` expands to when reducing with meta-language `target`
309    /// (e.g. `py↓` inside a Rust meta-program invokes Python evaluation).
310    /// The homogeneous case is `target` == `""` (no annotation); the default
311    /// ignores `target`, preserving existing behavior for metas without
312    /// heterogeneous support.
313    #[inline]
314    fn reduce_str(&self, target: &str) -> Result<&'static str> {
315        let _ = target;
316        Ok(REDUCE)
317    }
318    /// The spelling `↓` expands to in *method position* — the glyph flush
319    /// against an argument list, `recv.↓(term)`: a bare method name, which
320    /// the source's own parentheses complete. This is machine-directed
321    /// reduce (`db.↓(schema)` evaluates a term on a machine value, issue
322    /// #268), so hosts spell it as their machine-eval method.
323    ///
324    /// The default is an error, but unlike the other spellings it is not the
325    /// end of the line: a host that returns one has not *opted into* the
326    /// method-position reading, so the expander falls back to the operator
327    /// spelling — the meaning a flush `(` had before this rule existed, and
328    /// still the right one for `gen(7).↓(6)` in TypeScript, which reduces a
329    /// generated function and calls it. Only a host that answers the
330    /// un-annotated case and then refuses an annotated one gets its error
331    /// surfaced.
332    #[inline]
333    fn reduce_method_str(&self, target: &str) -> Result<&'static str> {
334        miette::bail!(
335            "this meta-language has no machine-eval spelling for `{target}↓(…)` in method position"
336        )
337    }
338    /// The spelling `←` expands to. Like [`Self::lift_str`] this returns a
339    /// `Result` because not every meta-language *has* an emit: a string-based
340    /// meta (nix, lean) has no `b_` accumulator to emit into, and must fail
341    /// loudly rather than leak the [`EMIT`] placeholder into generated code.
342    #[inline]
343    fn emit_str(&self) -> Result<&'static str> {
344        Ok(EMIT)
345    }
346    /// The spelling `↑` expands to inside an unquote of a quote with
347    /// representation `repr` (`ts⟨str⟩↖ … ↙↑(x)↘ … ↗`), where the lifted value
348    /// must be of that representation. `Repr::Cst` is [`Self::lift_str`].
349    fn lift_str_in(&self, target: &str, repr: crate::qterm::Repr) -> Result<&'static str> {
350        match repr {
351            crate::qterm::Repr::Cst => self.lift_str(target),
352            _ => Err(no_repr(repr)),
353        }
354    }
355    /// The spelling `←` expands to inside an unquote of a quote with
356    /// representation `repr`. `Repr::Cst` is [`Self::emit_str`].
357    fn emit_str_in(&self, repr: crate::qterm::Repr) -> Result<&'static str> {
358        match repr {
359            crate::qterm::Repr::Cst => self.emit_str(),
360            _ => Err(no_repr(repr)),
361        }
362    }
363    /// Code that builds a quote's value in representation `repr` — `⟨str⟩` or
364    /// `⟨qt⟩`; `⟨cst⟩` quotes go through [`Self::expand_quote`] and friends —
365    /// from its flattened `pieces`. `lang2` is the quoted language.
366    fn expand_flat(
367        &self,
368        repr: crate::qterm::Repr,
369        lang2: &str,
370        pieces: &[Piece],
371    ) -> Result<Arc<QTerm>> {
372        let _ = (lang2, pieces);
373        Err(no_repr(repr))
374    }
375    /// The spelling `⟨T⟩` expands to: the type of a quilt term in this host's
376    /// meta-code (`Arc<QTerm>` for Rust). `Result` because a host language
377    /// without a way to write types has no spelling for it.
378    #[inline]
379    fn type_str(&self) -> Result<&'static str> {
380        Ok(TYPE)
381    }
382    /// The spelling `⟨N⟩` expands to: the function taking a string to an
383    /// identifier term (`name` for Rust). In a string-based meta a name is its
384    /// own text, so this is the host's identity function.
385    #[inline]
386    fn name_str(&self) -> Result<&'static str> {
387        Ok(NAME)
388    }
389    /// The spelling `⟨T⟩` expands to in *method position* — the glyph flush
390    /// against an argument list, `db.⟨T⟩(term)`: the machine's *typing*
391    /// judgment, the companion of [`Self::reduce_method_str`]'s value
392    /// judgment (issue #273). A bare method name, completed by the source's
393    /// own parentheses; `⟨T⟩` anywhere else keeps meaning the term type.
394    ///
395    /// Falls back to [`Self::type_str`] on `Err`, for the same reason
396    /// [`Self::reduce_method_str`] falls back to the operator spelling.
397    #[inline]
398    fn type_method_str(&self) -> Result<&'static str> {
399        miette::bail!("this meta-language has no type-of spelling for `⟨T⟩(…)` in method position")
400    }
401    /// The spelling `lang⟨M⟩` expands to: an expression obtaining a machine
402    /// speaking `lang` (issue #273). The annotation is already resolved by
403    /// the expander, so `lang` is a concrete language name — which is why
404    /// this is the one spelling that is not a `&'static str`.
405    ///
406    /// The default is an honest error naming what would unblock it, like
407    /// every other spelling a host may lack: a string-based meta (nix, lean)
408    /// has no runtime to hold a machine handle, so it needs the out-of-process
409    /// daemon from issue #268 rather than a spelling.
410    #[inline]
411    fn spawn_str(&self, lang: &str) -> Result<String> {
412        miette::bail!(
413            "this meta-language has no spelling for `{lang}⟨M⟩`: it has no runtime to hold a \
414             machine handle. Drive the machine from a host that does (rust, python), or wait on \
415             the `quilt machine serve` daemon (issue #268)"
416        )
417    }
418
419    /// What must be in scope for the code this meta generates: the runtime
420    /// import an expanded file opens with (issue #274). `None` — the default —
421    /// means this host needs none.
422    ///
423    /// It belongs here rather than on [`Language`](crate::lang::Language)
424    /// because the import exists to satisfy the *expander's output*, and the
425    /// output vocabulary is the meta's business: `ops.rs` is what decides a
426    /// quote becomes `tb("block").c(…)`. A quotable-only target (wgsl, html,
427    /// sql, the shells) has no meta and needs no prelude, and a string-based
428    /// meta (nix, lean, text) calls no runtime at all, so both get the right
429    /// answer from this default.
430    ///
431    /// `targets` are the object languages the file may lift into — the file's
432    /// language chain plus every annotation its quotes name. Rust and Python
433    /// ignore them and return one glob import; TypeScript, whose lift spelling
434    /// is target-directed (see [`Self::lift_str`]), builds its named import
435    /// list from them, which is the half of this that a human gets wrong.
436    ///
437    /// The injection itself belongs to what writes the file — `quilt expand`,
438    /// `quilt run` and the in-browser expander, through
439    /// [`Multi::prelude_for`](crate::multi::Multi::prelude_for) and
440    /// [`with_prelude`] — not to expansion: a prelude is a property of the
441    /// *file written*, not of the term, so `quilt check` stays a pure
442    /// parse-and-expand and the expander snapshots do not carry it.
443    #[inline]
444    fn prelude(&self, targets: &[&str]) -> Option<Prelude> {
445        let _ = targets;
446        None
447    }
448}
449
450/**************************************************************/
451
452impl MetaLanguage for Box<dyn MetaLanguage> {
453    fn expand_quote(
454        &self,
455        lang1: &str,
456        tag: &str,
457        i: Index,
458        lang2: &str,
459        qterm: &Arc<QTerm>,
460        cmds: &[CmdOrHole],
461    ) -> Result<Arc<QTerm>> {
462        (**self).expand_quote(lang1, tag, i, lang2, qterm, cmds)
463    }
464
465    fn expand_unquote(
466        &self,
467        lang1: &str,
468        tag: &str,
469        i: Index,
470        lang2: &str,
471        qterm: &Arc<QTerm>,
472        cmds: &[CmdOrHole],
473    ) -> Result<Arc<QTerm>> {
474        (**self).expand_unquote(lang1, tag, i, lang2, qterm, cmds)
475    }
476
477    fn expand_tuple(
478        &self,
479        lang1: &str,
480        tag: &str,
481        qterms: &[Arc<QTerm>],
482        cmds: &[CmdOrHole],
483        arity: Arity, // should we split expand_tuple based on variadic vs not?
484    ) -> Result<Arc<QTerm>> {
485        (**self).expand_tuple(lang1, tag, qterms, cmds, arity)
486    }
487
488    fn wrap_child(&self, qterm: Arc<QTerm>, okind: OuterKind) -> Result<Arc<QTerm>> {
489        (**self).wrap_child(qterm, okind)
490    }
491
492    fn wrap_separated(&self, qterm: Arc<QTerm>, sep: &str) -> Result<Arc<QTerm>> {
493        (**self).wrap_separated(qterm, sep)
494    }
495
496    fn pattern_tag(&self) -> Option<&'static str> {
497        (**self).pattern_tag()
498    }
499
500    fn pattern_binding(&self, terms: &[Arc<QTerm>]) -> Option<(usize, usize)> {
501        (**self).pattern_binding(terms)
502    }
503
504    fn pattern_var(&self, name: &str) -> Result<Arc<QTerm>> {
505        (**self).pattern_var(name)
506    }
507
508    fn pattern_let(
509        &self,
510        names: &[Box<str>],
511        pattern: &Arc<QTerm>,
512        value: &Arc<QTerm>,
513    ) -> Result<(Arc<QTerm>, Arc<QTerm>)> {
514        (**self).pattern_let(names, pattern, value)
515    }
516
517    fn lift_str(&self, target: &str) -> Result<&'static str> {
518        (**self).lift_str(target)
519    }
520
521    fn reduce_str(&self, target: &str) -> Result<&'static str> {
522        (**self).reduce_str(target)
523    }
524
525    fn reduce_method_str(&self, target: &str) -> Result<&'static str> {
526        (**self).reduce_method_str(target)
527    }
528
529    fn emit_str(&self) -> Result<&'static str> {
530        (**self).emit_str()
531    }
532
533    fn lift_str_in(&self, target: &str, repr: crate::qterm::Repr) -> Result<&'static str> {
534        (**self).lift_str_in(target, repr)
535    }
536
537    fn emit_str_in(&self, repr: crate::qterm::Repr) -> Result<&'static str> {
538        (**self).emit_str_in(repr)
539    }
540
541    fn expand_flat(
542        &self,
543        repr: crate::qterm::Repr,
544        lang2: &str,
545        pieces: &[Piece],
546    ) -> Result<Arc<QTerm>> {
547        (**self).expand_flat(repr, lang2, pieces)
548    }
549
550    fn type_str(&self) -> Result<&'static str> {
551        (**self).type_str()
552    }
553
554    fn name_str(&self) -> Result<&'static str> {
555        (**self).name_str()
556    }
557
558    fn type_method_str(&self) -> Result<&'static str> {
559        (**self).type_method_str()
560    }
561
562    fn spawn_str(&self, lang: &str) -> Result<String> {
563        (**self).spawn_str(lang)
564    }
565
566    fn prelude(&self, targets: &[&str]) -> Option<Prelude> {
567        (**self).prelude(targets)
568    }
569}
570
571#[cfg(all(test, feature = "parse"))]
572mod tests {
573    use super::*;
574
575    /// The injected runtime import goes *after* the file's header, because
576    /// Rust's `//!` and `#![…]` are inner and inner means "before any item" —
577    /// an import above them is a syntax error, not a style choice.
578    #[test]
579    fn a_prelude_goes_after_the_header() {
580        // Each case names where the first *item* starts, so the expected
581        // offset is read off the fixture rather than counted by hand.
582        let at = |body: &str, comment: &str, item: &str| {
583            assert_eq!(
584                prelude_offset(body, comment),
585                body.find(item).unwrap(),
586                "{body:?}"
587            );
588        };
589        // Nothing to skip.
590        at("fn main() {}\n", "//", "fn");
591        // A doc header, its trailing blank line included.
592        at("//! docs\n//! more\n\nfn main() {}\n", "//", "fn");
593        // A shebang, and only on the first line.
594        at("#!/usr/bin/env quilt\nfn main() {}\n", "//", "fn");
595        at("fn main() {}\n#!/usr/bin/env quilt\n", "//", "fn");
596        // An inner attribute is taken whole, brackets balanced across lines.
597        at("#![allow(dead_code)]\nfn f() {}\n", "//", "fn");
598        at("#![allow(\n    dead_code\n)]\nfn f() {}\n", "//", "fn");
599        // An unbalanced one stops the scan rather than splitting it.
600        at("#![allow(\nfn f() {}\n", "//", "#![");
601        // Python's introducer covers its shebang and its comments alike.
602        at("#!/usr/bin/env quilt\n# hi\nx = 1\n", "#", "x =");
603    }
604}