diff options
| author | kr.angelov <kr.angelov@gmail.com> | 2013-09-27 15:09:48 +0000 |
|---|---|---|
| committer | kr.angelov <kr.angelov@gmail.com> | 2013-09-27 15:09:48 +0000 |
| commit | 426bc49a52b4efa0ef0129d713842d8c9abdf0ff (patch) | |
| tree | d9f5985559de0347448e77ff26ce5a2d3ee2f245 /src/runtime/c/pgf/printer.c | |
| parent | b138899512d9aea248160eb17df3007e55dd03da (diff) | |
a major refactoring in the C and the Haskell runtimes. Note incompatible change in the PGF format!!!
The following are the outcomes:
- Predef.nonExist is fully supported by both the Haskell and the C runtimes
- Predef.BIND is now an internal compiler defined token. For now
it behaves just as usual for the Haskell runtime, i.e. it generates &+.
However, the special treatment will let us to handle it properly in
the C runtime.
- This required a major change in the PGF format since both
nonExist and BIND may appear inside 'pre' and this was not supported
before.
Diffstat (limited to 'src/runtime/c/pgf/printer.c')
| -rw-r--r-- | src/runtime/c/pgf/printer.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/runtime/c/pgf/printer.c b/src/runtime/c/pgf/printer.c index 79aac5afd..82ce0bf45 100644 --- a/src/runtime/c/pgf/printer.c +++ b/src/runtime/c/pgf/printer.c @@ -196,19 +196,16 @@ pgf_print_cncfun(PgfCncFun *cncfun, PgfSequences* sequences, } static void -pgf_print_tokens(PgfTokens* tokens, GuOut *out, GuExn *err) +pgf_print_token(PgfToken tok, GuOut *out, GuExn *err) { gu_putc('"', out, err); - size_t n_toks = gu_seq_length(tokens); - for (size_t i = 0; i < n_toks; i++) { - if (i > 0) gu_putc(' ', out, err); - - PgfToken tok = gu_seq_get(tokens, PgfToken, i); - gu_string_write(tok, out, err); - } + gu_string_write(tok, out, err); gu_putc('"', out, err); } +static void +pgf_print_sequence(PgfSequence* seq, GuOut *out, GuExn *err); + void pgf_print_symbol(PgfSymbol sym, GuOut *out, GuExn *err) { @@ -220,18 +217,18 @@ pgf_print_symbol(PgfSymbol sym, GuOut *out, GuExn *err) } case PGF_SYMBOL_KS: { PgfSymbolKS* sks = gu_variant_data(sym); - pgf_print_tokens(sks->tokens, out, err); + pgf_print_token(sks->token, out, err); break; } case PGF_SYMBOL_KP: { PgfSymbolKP* skp = gu_variant_data(sym); gu_puts("pre {", out, err); - pgf_print_tokens(skp->default_form, out, err); + pgf_print_sequence(skp->default_form, out, err); for (size_t i = 0; i < skp->n_forms; i++) { gu_puts("; ", out, err); - pgf_print_tokens(skp->forms[i].form, out, err); + pgf_print_sequence(skp->forms[i].form, out, err); gu_puts(" / ", out, err); size_t n_prefixes = gu_seq_length(skp->forms[i].prefixes); @@ -262,16 +259,18 @@ pgf_print_symbol(PgfSymbol sym, GuOut *out, GuExn *err) gu_puts("nonExist", out, err); break; } + case PGF_SYMBOL_BIND: { + gu_puts("BIND", out, err); + break; + } default: gu_impossible(); } } static void -pgf_print_sequence(size_t seqid, PgfSequence* seq, GuOut *out, GuExn *err) +pgf_print_sequence(PgfSequence* seq, GuOut *out, GuExn *err) { - gu_printf(out,err," S%d := ", seqid); - int n_syms = gu_seq_length(seq); for (int i = 0; i < n_syms; i++) { if (i > 0) gu_putc(' ', out, err); @@ -279,8 +278,6 @@ pgf_print_sequence(size_t seqid, PgfSequence* seq, GuOut *out, GuExn *err) PgfSymbol sym = gu_seq_get(seq, PgfSymbol, i); pgf_print_symbol(sym, out, err); } - - gu_putc('\n', out, err); } static void @@ -342,7 +339,10 @@ pgf_print_concrete(PgfCId cncname, PgfConcr* concr, size_t n_seqs = gu_seq_length(concr->sequences); for (size_t i = 0; i < n_seqs; i++) { PgfSequence* seq = gu_seq_get(concr->sequences, PgfSequence*, i); - pgf_print_sequence(i, seq, out, err); + + gu_printf(out,err," S%d := ", i); + pgf_print_sequence(seq, out, err); + gu_putc('\n', out, err); } gu_puts(" categories\n", out, err); |
