|
| 1 | +# This file is part of the Zephir Parser. |
| 2 | +# |
| 3 | +# (c) Zephir Team <team@zephir-lang.com> |
| 4 | +# |
| 5 | +# For the full copyright and license information, please view |
| 6 | +# the LICENSE file that was distributed with this source code. |
| 7 | + |
| 8 | +Write-Output "-- Compiling Lemon parser..." |
| 9 | +$LemonSrc = Join-Path -Path './parser' -ChildPath 'lemon.c' |
| 10 | +$LemonBin = Join-Path -Path './parser' -ChildPath 'lemon.exe' |
| 11 | + |
| 12 | +if ($IsWindows) { |
| 13 | + & cl /Fe${LemonExe} ${LemonSrc} |
| 14 | +} |
| 15 | +else { |
| 16 | + $LemonBin = Join-Path -Path './parser' -ChildPath 'lemon' |
| 17 | + & gcc ${LemonSrc} -o ${LemonBin} |
| 18 | +} |
| 19 | +& ${LemonBin} -x |
| 20 | + |
| 21 | +Write-Output "-- Cleanup initial file state..." |
| 22 | + |
| 23 | +$AutoFiles = "./parser/zephir.c", |
| 24 | + "./parser/zephir.h", |
| 25 | + "./parser/parser.c", |
| 26 | + "./parser/scanner.c" |
| 27 | + |
| 28 | +foreach ($GeneratedFile in $AutoFiles) { |
| 29 | + if (Test-Path -Path $GeneratedFile) { |
| 30 | + Remove-Item $GeneratedFile |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +Write-Output "-- Run re2c..." |
| 35 | +& re2c -o (Join-Path -Path './parser' -ChildPath 'scanner.c') (Join-Path -Path './parser' -ChildPath 'scanner.re') |
| 36 | + |
| 37 | +Write-Output "-- Generating zephir.c file with lemon parser..." |
| 38 | +& ${LemonBin} -s (Join-Path -Path './parser' -ChildPath 'zephir.lemon') |
| 39 | + |
| 40 | +Write-Output "-- Generating parser.c file..." |
| 41 | +$ParserC = Join-Path -Path './parser' -ChildPath 'parser.c' |
| 42 | +$ZephirC = Join-Path -Path './parser' -ChildPath 'zephir.c' |
| 43 | +$BaseC = Join-Path -Path './parser' -ChildPath 'base.c' |
| 44 | +Set-Content -Path ${ParserC} -Value '#include <php.h>' |
| 45 | +Get-Content ${ZephirC}, ${BaseC} | Add-Content ${ParserC} |
0 commit comments