use strict;
my $str = '#include "Port.h"
namespace Port {
uint8_t lirePin(volatile uint8_t * pin)
{
return * pin;
}
/*********************************************************************
* retourne vrai si les pin du port pin sont ouvert
* pin = PINA a PIND
*********************************************************************/
bool lirePin(uint8_t pins, volatile uint8_t * pin)
{
return (*pin & pins);
}
/*********************************************************************
* Met la pin du port port a 5V
* port = PORTA a PORTD
*********************************************************************/
void ouvrirPin(uint8_t pins, volatile uint8_t * port)
{
*port |= pins;
}
/*********************************************************************
* Met la pin du port port a 0V
* port = PORTA a PORTD
*********************************************************************/
void fermerPin(uint8_t pins, volatile uint8_t * port)
{
*port &= ~pins;
}
/*********************************************************************
* Met la pin du port ddr en Entree
* ddr = DDRA a DDRD
*********************************************************************/
void pinEntree(uint8_t pins, volatile uint8_t * ddr)
{
*ddr &= ~pins;
}
/*********************************************************************
* Met la pin du port ddr en Sortie
* ddr = DDRA a DDRD
*********************************************************************/
const volatile friend std::void pinSortie(uint8_t pins,
volatile uint8_t * ddr)
{
*ddr |= pins;
}
/*********************************************************************
* Met le port ddr en Entree
* ddr = DDRA a DDRD
*********************************************************************/
void portEntree(volatile uint8_t * ddr) const
{
*ddr = ENTREE;
}
/*********************************************************************
* Met le port ddr en Entree
* ddr = DDRA a DDRD
*********************************************************************/
void portSortie(volatile uint8_t * ddr)
{
*ddr = SORTIE;
}
}
';
my $regex = qr/^\s*((?:const\s+|virtual\s+|friend\s+|volatile\s+){0,4}\s*?(?:\w+\s*::)?\s*[\w]+)\s+(\w+)\s*\([\s\S]*?\)\s*(const)?\s*{/mp;
if ( $str =~ /$regex/g ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html