Skip to content

Commit

Permalink
PodWeaver tags are now parsed as head2
Browse files Browse the repository at this point in the history
  • Loading branch information
hurricup committed Feb 14, 2019
1 parent 6dc27be commit 63c70e5
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/grammar/Pod.flex
Expand Up @@ -55,14 +55,16 @@ NUMBER_HEX = "0"[xX][0-9a-fA-F_]+
NUMBER_BIN = "0"[bB][01_]+
NUMBER = {NUMBER_HEX} | {NUMBER_BIN}| {NUMBER_INT} | {NUMBER_SMALL}

HEAD2_TOKEN= "=head2" | "=method" | "=func" | "=attr"

%state LEX_PREPARSED_ITEMS
%state LEX_COMMAND_READY, LEX_COMMAND_WAITING
%%

<LEX_COMMAND_WAITING>{
"=pod" {yybegin(YYINITIAL);return POD_POD;}
"=head1" {yybegin(YYINITIAL);return POD_HEAD1;}
"=head2" {yybegin(YYINITIAL);return POD_HEAD2;}
{HEAD2_TOKEN} {yybegin(YYINITIAL);return POD_HEAD2;}
"=head3" {yybegin(YYINITIAL);return POD_HEAD3;}
"=head4" {yybegin(YYINITIAL);return POD_HEAD4;}
"=item" {yybegin(YYINITIAL);return POD_ITEM;}
Expand Down
2 changes: 2 additions & 0 deletions core/test/parser/PODParserTest.java
Expand Up @@ -31,6 +31,8 @@ protected String getTestDataPath() {
return "testData/parser/pod";
}

public void testPodWeaverTags() {doTest();}

public void testUnknownSectionWIthContent() {doTest();}

public void testHierarchy() {
Expand Down
35 changes: 35 additions & 0 deletions core/testData/parser/pod/podWeaverTags.code
@@ -0,0 +1,35 @@

=head1 METHODS

=method somemethod

Method description

=head1 ATTRIBUTES

=attr someattr

Attribute description

=head1 FUNCTIONS

=func somefunc

Function dscription

=head1 OVERVIEW

Some overview text

=method othermethod

Other method description

=func otherfunc

Other func description

=attr otherattr

Other attr description

92 changes: 92 additions & 0 deletions core/testData/parser/pod/podWeaverTags.txt
@@ -0,0 +1,92 @@
POD file
PsiHead1SectionImpl(Perl5 POD: HEAD_1_SECTION)
PsiElement(Perl5 POD: POD_HEAD1)('=head1')
PsiSectionTitleImpl(Perl5 POD: SECTION_TITLE)
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('METHODS')
PsiElement(Perl5 POD: POD_NEWLINE)('\n')
PsiHead1SectionContentImpl(Perl5 POD: HEAD_1_SECTION_CONTENT)
PsiHead2SectionImpl(Perl5 POD: HEAD_2_SECTION)
PsiElement(Perl5 POD: POD_HEAD2)('=method')
PsiSectionTitleImpl(Perl5 POD: SECTION_TITLE)
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('somemethod')
PsiElement(Perl5 POD: POD_NEWLINE)('\n')
PsiHead2SectionContentImpl(Perl5 POD: HEAD_2_SECTION_CONTENT)
PsiPodParagraphImpl(Perl5 POD: POD_PARAGRAPH)
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('Method')
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('description')
PsiElement(Perl5 POD: POD_NEWLINE)('\n')
PsiHead1SectionImpl(Perl5 POD: HEAD_1_SECTION)
PsiElement(Perl5 POD: POD_HEAD1)('=head1')
PsiSectionTitleImpl(Perl5 POD: SECTION_TITLE)
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('ATTRIBUTES')
PsiElement(Perl5 POD: POD_NEWLINE)('\n')
PsiHead1SectionContentImpl(Perl5 POD: HEAD_1_SECTION_CONTENT)
PsiHead2SectionImpl(Perl5 POD: HEAD_2_SECTION)
PsiElement(Perl5 POD: POD_HEAD2)('=attr')
PsiSectionTitleImpl(Perl5 POD: SECTION_TITLE)
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('someattr')
PsiElement(Perl5 POD: POD_NEWLINE)('\n')
PsiHead2SectionContentImpl(Perl5 POD: HEAD_2_SECTION_CONTENT)
PsiPodParagraphImpl(Perl5 POD: POD_PARAGRAPH)
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('Attribute')
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('description')
PsiElement(Perl5 POD: POD_NEWLINE)('\n')
PsiHead1SectionImpl(Perl5 POD: HEAD_1_SECTION)
PsiElement(Perl5 POD: POD_HEAD1)('=head1')
PsiSectionTitleImpl(Perl5 POD: SECTION_TITLE)
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('FUNCTIONS')
PsiElement(Perl5 POD: POD_NEWLINE)('\n')
PsiHead1SectionContentImpl(Perl5 POD: HEAD_1_SECTION_CONTENT)
PsiHead2SectionImpl(Perl5 POD: HEAD_2_SECTION)
PsiElement(Perl5 POD: POD_HEAD2)('=func')
PsiSectionTitleImpl(Perl5 POD: SECTION_TITLE)
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('somefunc')
PsiElement(Perl5 POD: POD_NEWLINE)('\n')
PsiHead2SectionContentImpl(Perl5 POD: HEAD_2_SECTION_CONTENT)
PsiPodParagraphImpl(Perl5 POD: POD_PARAGRAPH)
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('Function')
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('dscription')
PsiElement(Perl5 POD: POD_NEWLINE)('\n')
PsiHead1SectionImpl(Perl5 POD: HEAD_1_SECTION)
PsiElement(Perl5 POD: POD_HEAD1)('=head1')
PsiSectionTitleImpl(Perl5 POD: SECTION_TITLE)
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('OVERVIEW')
PsiElement(Perl5 POD: POD_NEWLINE)('\n')
PsiHead1SectionContentImpl(Perl5 POD: HEAD_1_SECTION_CONTENT)
PsiPodParagraphImpl(Perl5 POD: POD_PARAGRAPH)
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('Some')
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('overview')
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('text')
PsiElement(Perl5 POD: POD_NEWLINE)('\n')
PsiHead2SectionImpl(Perl5 POD: HEAD_2_SECTION)
PsiElement(Perl5 POD: POD_HEAD2)('=method')
PsiSectionTitleImpl(Perl5 POD: SECTION_TITLE)
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('othermethod')
PsiElement(Perl5 POD: POD_NEWLINE)('\n')
PsiHead2SectionContentImpl(Perl5 POD: HEAD_2_SECTION_CONTENT)
PsiPodParagraphImpl(Perl5 POD: POD_PARAGRAPH)
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('Other')
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('method')
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('description')
PsiElement(Perl5 POD: POD_NEWLINE)('\n')
PsiHead2SectionImpl(Perl5 POD: HEAD_2_SECTION)
PsiElement(Perl5 POD: POD_HEAD2)('=func')
PsiSectionTitleImpl(Perl5 POD: SECTION_TITLE)
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('otherfunc')
PsiElement(Perl5 POD: POD_NEWLINE)('\n')
PsiHead2SectionContentImpl(Perl5 POD: HEAD_2_SECTION_CONTENT)
PsiPodParagraphImpl(Perl5 POD: POD_PARAGRAPH)
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('Other')
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('func')
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('description')
PsiElement(Perl5 POD: POD_NEWLINE)('\n')
PsiHead2SectionImpl(Perl5 POD: HEAD_2_SECTION)
PsiElement(Perl5 POD: POD_HEAD2)('=attr')
PsiSectionTitleImpl(Perl5 POD: SECTION_TITLE)
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('otherattr')
PsiElement(Perl5 POD: POD_NEWLINE)('\n')
PsiHead2SectionContentImpl(Perl5 POD: HEAD_2_SECTION_CONTENT)
PsiPodParagraphImpl(Perl5 POD: POD_PARAGRAPH)
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('Other')
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('attr')
PodIdentifierImpl(Perl5 POD: POD_IDENTIFIER)('description')

0 comments on commit 63c70e5

Please sign in to comment.