image thumbnail
from toy compiler by Bill McKeeman
A toy compiler

toy(src)
% FILE:    toy.m
% PURPOSE: run the toy compiler, see the x86 asm
% USAGE:   toy 'x=1;'

function toy(src)
  [tc, ts, te] = lexer(src);            % lex source text
  sr = parser(tc);                      % parse token codes
  asm = gen(src, tc, ts, te, sr);       % emit assembler text 

  % Display results
  disp(src);                            % the source text
  disp(asm);                            % corresponding assembler input

Contact us at files@mathworks.com