stm32f103 Bluepill usb keyboard demo cmake project (it worked!)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
stm32f103-usb-keyboard/find_docblocks.php

34 lines
747 B

#!/bin/env php
<?php
if ($argc != 3) {
echo "[E] Need 2 arguments: (.c file), (.h file)\n";
exit;
}
$cfile = $argv[1];
$hfile = $argv[2];
if (!file_exists($cfile)) {
echo "[E] File not found.\n";
exit;
}
$ctxt = file_get_contents($cfile);
$htxt = file_get_contents($hfile);
preg_match_all('/(\/\*\*(?:.(?!\/\*\*))*?\*\/)\s+([a-z_+0-9]+)\s+([a-z_+0-9]+)\s*(?=\()/si', $ctxt, $matches);
$dox = $matches[1];
$types = $matches[2];
$names = $matches[3];
$x = $htxt;
for ($i = 0; $i < count($dox); $i++) {
$search = '/' . preg_quote($types[$i]) . '\s+' . preg_quote($names[$i]) . '/';
$replacement = "\n\n/*- injected dox -*/\n" . $dox[$i] . "\n" . $types[$i] . ' ' . $names[$i];
$x = preg_replace($search, $replacement, $x);
}
echo $x;