En gros, le principe, c'est de créer un logiciel qui peut analyser un breakdown, dire s'il est grammaticalement correct, et ensuite, on peut en faire ce qu'on veut. Notamment, c'est la première étape pour faire ce que Zombo décrit dans son topic "Analyse formelle".
_______________________________________________________________________________________________________
Work in progress. Grammaire pour http://treetop.rubyforge.org/, mais c'est très facile à convertir vers une autre syntaxe de PEG.
Code : Tout sélectionner
grammar Breakdown
rule breakdown
space? full_trick_breakdown ( space ( '>' / '~>' / '>~' / '~' ) space full_trick_breakdown )* space?
end
rule full_trick_breakdown
(parenthesis space?)*
full_trick_name
(space? extended_notation)?
(space? parenthesis)*
end
rule full_trick_name
simple_full_trick_name (space aerial_name)? (space number)? (space fingerslots)?
end
rule simple_full_trick_name
modifiers? trick_name (space direction)?
end
rule extended_notation
ext_push? ext_spin? ext_catch?
end
rule ext_push
'[p' (space fingerslot)? ']'
end
rule ext_spin
'[s' space number ']'
end
rule ext_catch
'[c]'
end
rule modifiers
(('Quadruple' / 'Triple' / 'Double' / 'Single') space)? 'Inverse '? 'Inverted '? 'Moonwalk '?
end
rule trick_name
(finger_name+) "around" /
"Anti-gravity" /
finger_name "backaround" / "Backaround" /
(finger_name / "Void") "swivel" / "Swivel" /
"Bakriser" / body_part " Bounce" / "Leigun" / "Levitator" / finger_name " Snap" /
(("Twisted" / "Demon's" / "Angel's"/ "Devil's" / "In-Out" / "Out-In" / "East") space)? 'Sonic' /
"Shadow" " still"? /
(finger_name+) "spin"/
'Pass' / 'Wiper' / "Charge" / "Triangle pass" / "Fingerswitch" / "Neobackaround" / "Anti-gravity"
end
rule aerial_name
"Release" / "Riser" / "Pop" / "Riser Pop"
end
rule body_part
finger_name / "Arm" / "Wrist" / "Palm" / "Backhand"
end
rule finger_name
'Pinky' / 'Ring' / 'Middle' / 'Index' / 'Thumb'
end
rule fingerslots
fingerslot ( '-' fingerslot )*
end
rule fingerslot
zone+
end
rule zone
'1' / '2' / '3' / '4' / 'P' / 'B' / 'T'
end
rule parenthesis
'(' (
palm_position / style / impulse
) ')'
end
rule palm_position
"palm " ("down" / "up" / "side") / "inverse palm side"
end
rule style
("weissan" / "korean") " style"
end
rule impulse
full_trick_name " impulse"
end
rule direction
'reverse' / 'normal'
end
rule number
('0' / [1-9] [0-9]*) '.' ('0' / '5' / '25' / '33')
end
rule space
(' ' / "\n" / "\t")+
end
end