Strategic Communication to C compiler
fix number literal reference in README
ignore unused arguments

heads

tip
browse log

clone

read-only
https://hg.sr.ht/~nprescott/stratcom
read/write
ssh://hg@hg.sr.ht/~nprescott/stratcom


strategic-communication
═══════════════════════

  strategic-communication was designed and first implemented by the user
  [rotoclone on github], where it was described as:

        A best-of-breed language with a holistic approach to
        moving the needle.

  Also noted in the original is the following:

        The way I implemented the interpreter is super naive; it
        re-parses every line it executes from its string
        representation every time. There are likely other easy
        performance gains I've ignored as well.

  In an effort to improve performance and expand target architectures
  I've implemented a compiler from strategic-communication to C,
  implemented here in Common Lisp.

  This README is modified from the original and all of the example
  programs are borrowed from there to ensure program compatibility.


[rotoclone on github]
https://github.com/rotoclone/strategic-communication

Register names
──────────────

  There are 8 available registers. Each one starts with a value of 0,
  and can hold any 32-bit signed integer. They are named as follows:
  • customer experience
  • revenue streams
  • core competencies
  • best practices
  • stakeholder engagement
  • key performance indicators
  • return on investment
  • assets


Constants
─────────

  There are 10 constants used to represent literal numbers

  0. HR
  1. Engineering
  2. Legal
  3. PR
  4. Finance
  5. Marketing
  6. R&D
  7. Sales
  8. Manufacturing
  9. Executive Management


Operations
──────────

  A Strategic Communication program consists of a series of operations
  separated by newlines.

  Unless otherwise denoted, all operands must be register names.

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   Description                                                                  Formats                                  Notes                                                           
  ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   increment the value in `x'                                                   `innovate x' `value-add x'                                                                               
   decrement the value in `x'                                                   `streamline x' `optimize x'                                                                              
   multiply the value in `x' by -1                                              `revamp x' `overhaul x'                                                                                  
   multiply the value in `x' by 2                                               `amplify x' `incentivize x'                                                                              
   divide the value in `x' by 2                                                 `backburner x'                           any remainder is discarded                                      
   set the value in `x' to a random number between 0 and 9 inclusive            `paradigm shift x'                                                                                       
   set the value in `x' to the value in `y'                                     `align x with y'                         `y' can be a register name or a constant expression             
   set the value in `x' to the value of `y'                                     `align y with x'                         `y' must be a constant expression                               
   add the value in `x' to the value in `y' and store the result in `x'         `synergize x and y' `integrate x and y'                                                                  
   subtract the value in `y' from the value in `x' and store the result in `x'  `differentiate x and y'                                                                                  
   read a single byte from stdin and store it in `x'                            `crowdsource x'                          if EOF is encountered, the value in `x' is set to -1            
   print the value in `x' to stdout                                             `deliver x' `produce x'                  UTF-8 encoding will be used                                     
   define a label called `x'                                                    `moving forward, x' `going forward, x'   `x' can be any string containing no register names or constants 
   jump to label `x'                                                            `circle back to x' `revisit x'           `x' must be a defined label                                     
   jump to label `x' if the value in `y' is zero                                `pivot y to x'                           `x' must be a defined label                                     
   jump to label `x' if the value in `y' is negative                            `restructure y to x'                     `x' must be a defined label                                     
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━


Constant expressions
────────────────────

  A constant expression is a sequence of one or more constants separated
  by `,' or `and'. The value of the expression is the result of
  concatenating the values of the constants. For example, `Engineering'
  has a value of `1' and `Marketing' has a value of `5', so the
  expression `Engineering and Marketing' has a value of `15'.

  More examples:
  • `Engineering, Marketing, and HR' = `150'
  • `Engineering' = `1'
  • `HR and Engineering' = `1' (leading zeros are ignored)
  • `Marketing, Marketing, Marketing' = `555'


Running a program
─────────────────

  Invoking the compiler is possible with the function `compile-to-c', it
  takes a single argument of the strategic-communication program as a
  string and will write the resulting C code out to a file
  `t.c'. Subsequent runs will overwrite the file.

  If you happen to have `tcc' available you can run the generated
  program directly with the function `run':

  ┌────
  │   CL-USER> (run "align Engineering and HR with stakeholder engagement
  │ align revenue streams with stakeholder engagement
  │ revamp revenue streams
  │ align Finance and Manufacturing with customer experience
  │ moving forward, think outside the box
  │ deliver customer experience
  │ deliver stakeholder engagement
  │ innovate customer experience
  │ innovate revenue streams
  │ restructure revenue streams to think outside the box")
  │ 0
  │ 1
  │ 2
  │ 3
  │ 4
  │ 5
  │ 6
  │ 7
  │ 8
  │ 9
  │ NIL
  └────

  Further examples can be found in the [original github repository].


[original github repository]
https://github.com/rotoclone/strategic-communication/tree/7bf650ec85719b7026384762c5b65b8eaa13272d/examples