I wrote a perl6 grammar to analyze a c ++ function, my final goal would be to analyze a complete header.
The aim is not to correct the syntax errors of c ++, but to analyze valid c ++.
Do you have any tips or improvements?
#! / usr / bin / env perl6
grammar function {
TOP tab {
The[[ s +]? [s*[s*[s*[s* ]?
( s +) ( s *) "("
( s *)
The[[ [""(s*)[""(s*)[""(s*)[""(s*) ]*]? ( s *)
& # 39;) & # 39; ( s *) & # 39 ;; & # 39;
}
token name { w +}
token namespace { [ "::" ]?
The[[ "::"]*}
token attr { }
token type { ? }
token type_mod { [ *|& ]+}
name of card { }
token variable { }
Token parameter { [s*[s*[s*[s* ]? s + }
}
my $ str = "const :: one :: std :: string ** ma1n (int && i, two :: std :: string va1e_);";
my $ parsed = FUNCTION.parse ($ str);
say $ analyzed;