Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement macros / preprocessor #180

Closed
SciLor opened this issue Mar 12, 2018 · 3 comments
Closed

Implement macros / preprocessor #180

SciLor opened this issue Mar 12, 2018 · 3 comments

Comments

@SciLor
Copy link

SciLor commented Mar 12, 2018

To make it easier to write nice structured code it would be nice to have a preprocessor to make construction like that possible

scripts:
  bs_apfel:
    - $p_bs:=a $p_obj:=apfel $p_jmp:=_p_jmp_koestlich
    - J(_playBlock_jmp)

  bs_apfel2:
    - +playBlock_jmp(a, apfel, _p_jmp_koestlich)

  _p_jmp_koestlich:
    - P(koestlich, mhh_das_schmeckt, jam)

  _playBlock:
    - $p_jmp:=0
    - J(_play_jmp) P(nop)

  _playBlock_jmp:
    - P($p_bs) P(wait_0500ms)
    - P(wie_in) P(wait_0500ms)
    - P($p_obj) P(wait_1000ms)
    - $p_jmp!=0? J($p_jmp)

  _random:
    - T($r,65535) $random+=$r $random*=25173 $random+=13849 $ran2:=$random $ran2%=2 $ran3:=$random $ran3%=2 $ran4:=$random $ran4%=3
functions:
  playBlock_jmp:
    vars:
      - $p_bs
      - $p_obj
      - $p_jmp
    script:
      - J(_playBlock_jmp)

Ideas

  • Allow code in multiple lines. The preprocessor should put everything in a single line.
  • If lines are to long, split them up automatically by using jumps
  • Registeres are not possible with J/P. Analyse static code and generate all possiblities as code.
  • Implement "functions" see bs_apfel2
  • Implement "imports" to split everything up into several files, just concat all subsections, if there are multiple "scripts" sections and throw an error if there are circling imports or multiple product-id sections
@nomeata
Copy link
Member

nomeata commented Mar 13, 2018

I chose yaml as the input format to precisely enable that: People writing higher level tools that generate tttool-yaml. I am a bit wary of implementing high-level features in tttool directly … generating all possibilities as code can easily blow up.

Maybe people should experiment with their preprocessors, and useful stuff eventually goes into tttool proper.

@SciLor
Copy link
Author

SciLor commented Mar 15, 2018

Would be a good idea.

@nomeata
Copy link
Member

nomeata commented Nov 7, 2020

I don’t plan to do anything like this soon, so closing this. Maybe one should design a nice high-level langauge for tiptoi programming, with local variables, function parameters etc., and compile that down to the tiptoi…

@nomeata nomeata closed this as completed Nov 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants