Skip to content

Unit Description

Authors
Joe Starr, Ph.D. image

Joe Starr, Ph.D.

I specialize in computational knot theory. I’m also a professional embedded software engineer.

Class Diagram

classDiagram
   resolution_machine  *-- resolution_stack_t
   resolution_stack_t ..|> resolution_partial_t 
   resolution_machine  *-- prodstr_store_t 
   resolution_machine  *-- prodstr_obj_t
   class resolution_machine {
    + int execute(const prodstr_store_t *prod_store, resolution_stack_t *stack )
    - const production_obj_t* next_production(resolution_partial_t* partial, const prodstr_store_t *prod_store)
    - int resolve_symbol(const prodstr_obj_t *prd, resolution_stack_t *stack)
    }

   class resolution_partial_t{
    <<struct>> 
    const char* buff
    const char* buff_end_ptr
    char * partial_ptr 
    }

   class resolution_stack_t {
    <<struct>> 
    const resolution_partial_t * partials
    const resolution_partial_t * stack_end_ptr 
    resolution_partial_t * stack_ptr 
    }

    class prodstr_obj_t{
        <<external>>
    } 

    class prodstr_store_t{
            <<external>>
        } 

Libraries

None

Use Cases Satisfied

Functionality

Public Structures

Partial Buffer Structure

The buffer structure for partial resolutions. The buffer contains a start, end, and current pointer for the block of memory. This is essentially a c-string.

Resolution Stack Structure

A stack of partial resolution objects. The stack contains a start, end, and current pointer for the block of memory.

Public Functions

Execute Function

This process is described in the following state machines:

stateDiagram-v2
  state "Push entry to stack" as pes
  state "Step resolution of string" as res  
  state is_empty <<choice>>

    [*] --> pes
    pes --> res 
    res --> is_empty
    is_empty --> res : Stack is not empty
    is_empty --> [*]: Stack is empty
stateDiagram-v2
  state "Identify next production symbol" as inps 
  state "Pop stack" as pops  
  state "Execute resolution of production symbol" as erps  
  state "Execute terminal resolution of production symbol" as etrs 
  state "Push result of production symbol" as props  
  state is_end <<choice>>
  state is_full <<choice>>

    [*] --> inps
    inps --> is_end
    is_end --> pops: symbols are exhausted 
    pops --> [*]
    is_end --> is_full: Next symbol found
    is_full --> etrs: Stack is full 
    etrs --> [*]
    is_full --> erps: Stack has room remaining 
    erps --> props 
    props --> [*]

Private Functions

stateDiagram-v2
  state "Scan string for '%'" as ssf  
  state "Print up to found symbol" as props  
  state "Print full string" as ps 
  state "Clear symbol from string" as csfs 
  state "Identify production from store" as ipfs 
  state is_delim <<choice>>
  state is_found <<choice>>

    [*] --> ssf
    ssf --> is_found
    is_found --> is_delim : Symbol found 
    is_delim --> ssf: Is delimited 
    is_delim --> props: else 
    props --> csfs 
    csfs --> ipfs 
    ipfs --> [*] 
    is_found --> ps: else 
    ps --> [*]

Validation

Execute Function

Positive Tests

Valid inputs supplied to function

A valid store and stack are passed to the function.

Inputs:

A valid store and stack are passed to the function.

Expected Output:

The correct output is seen on the output stream.

[!test-card] "Induce a terminal resolution"

A valid store and stack are passed to the function. The combination induces a terminal resolution.

Inputs:

A valid store and stack.

Expected Output:

The correct output is seen on the output stream.

Negative Tests

Null inputs supplied to the function

A null configuration is passed to the function.

Inputs:

  • A null pointer is passed to the function:
  • For the store
  • For the stack
  • For the stream

Expected Output:

A negative response.

[!test-card] "Correctly formatted production symbol but not in store"

A valid configuration is passed to the function. A production contains a reference to a nonexistent production.

Inputs:

A configuration as described.

Expected Output:

A negative response.