A web-based application for extracting C code from Excel files and generating Excel formulas from control logic. This is a multi-phase system that analyzes C code, extracts parameters, identifies outputs, and prepares for automatic Excel formula generation.
- Excel File Reader: Read .xlsx and .xlsb files containing C code
- C Code Parser: Extract C functions from Excel cells with column-by-column scanning
- Batch Processing: Process single files or entire folders recursively
- AUTOSAR Support: Handles FUNC() macro patterns
- Web Interface: Modern UI with drag-and-drop file upload
- Template Support: Multiple extraction templates (TOCHIGI, PADAS)
- PADAS Template:
- Sheet-specific processing with SheetJS integration
- Multi-marker support: "変数名", "DefineVariable", "Input", and "Expected Value" markers
- Processes ALL marker locations found in same sheet
- Horizontal parameter layout extraction (変数名, DefineVariable, Expected Value)
- Vertical parameter layout extraction (Input)
- Robust empty cell detection (stops after 5 consecutive empty columns)
- Input/Output Classification: Automatic parameter type detection
- TOCHIGI Template: Vertical layout with section-based extraction
- Stub File Auto-Detection: Automatically finds and uploads matching .txt stub files
- Expected Value Marker: Extracts output parameters from "Expected Value" marker in PADAS templates
- Horizontal Layout: Parameter names in row+1, values in row+2 (same as 変数名/DefineVariable)
- Automatic Classification: All parameters tagged as "input" or "output" type
- Separate Counting: API returns input_count and output_count separately
- UI Display: Input parameters (blue) and output parameters (orange) shown in separate sections
- Template Support: PADAS only (TOCHIGI and ADAS5 output extraction not implemented)
- HTML Report: Generate downloadable reports with all extraction results
- Backend Logs: Includes execution logs from c_parser_history.log
- Comprehensive Data: C code, parameters, stub files, processing timestamps
- Clear Functionality: Reset UI and start fresh processing
- Rule-Based Pattern Translation: 5 core rules for common C patterns
- Rules Implemented:
- Direct Assignment:
output = input→=input - If/Else Selection: Conditional assignments →
=IF(condition, value_a, value_b) - Set-Only Latch: Sticky fault pattern →
=OR(fault=1, PREV_output=1) - Rising-Edge Hold: HoldEdge pattern → Multi-formula (edge, counter, output)
- Up-Counter: Counter with enable/reset →
=IF(reset, 0, IF(enable, PREV+1, PREV))
- Direct Assignment:
- Function Bundler: Groups Phase 1-4 data by function
- Formula Output: Shows formulas with rule names, dependencies, and warnings
- Current Limitation: Basic rules need enhancement to match more PADAS code patterns
- Status: Working for simple patterns (HoldEdge), needs improvement for complex logic
- Phase 3: Stub file content extraction and mapping (partially complete - auto-detection done)
- Phase 5 Enhancement: Improve pattern matching rules for real PADAS C code structures
pip install -r requirements.txt- Start the server:
python run.py-
Open browser to http://localhost:8000
-
Select template type (TOCHIGI or PADAS)
-
Upload files:
- Single file: Click "Select File"
- Batch processing: Click "Select Folder" (includes all subfolders)
-
Click "Generate Formula" to process
-
View results in the table and download HTML report
# Upload single file with PADAS template
curl -X POST "http://localhost:8000/api/upload" \
-F "file=@example.xlsx" \
-F "template=padas" \
-F "sheet_name=SheetName" \
-F "first_in_batch=true"
# Get recent logs
curl "http://localhost:8000/api/logs?lines=500"formula_generator/
├── src/
│ └── formula_generator/
│ ├── __init__.py
│ ├── excel_reader.py # Excel file handling
│ ├── c_parser.py # C code extraction and parsing
│ ├── parameter_parser.py # Parameter extraction (Phase 2 & 4)
│ ├── function_bundler.py # Combine Phase 1-4 data (Phase 5)
│ └── formula_generator.py # Rule-based formula generation (Phase 5)
├── tests/
│ ├── __init__.py
│ └── test_analyzer.py
├── examples/
│ └── sample_usage.py
├── requirements.txt
├── pyproject.toml
└── README.md
Run tests:
pytest tests/MIT