Files
gp4/tree-sitter-p4/test/corpus/declarations.txt
T
Will Hawkins cfe78a9b29 Semicolon Cleanup
1. Semicolons were required in the wrong spot.
2. Make semicolons "invisible" (from the tree-sitter perspective).

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
2026-02-27 08:23:27 -05:00

189 lines
2.7 KiB
Plaintext

=========================
Simple Declaration
=========================
parser simple() {
state start {
bool l;
transition accept;
}
};
---
(p4program
(declaration
(parserDeclaration
(parserType
(parser)
(identifier)
)
(parserStates
(parserState
(state)
(identifier)
(parserLocalElements
(parserLocalElement
(variableDeclaration
(typeRef
(baseType
(bool)
)
)
(identifier)
)
)
)
(parserTransitionStatement
(transition)
(transitionSelectionExpression
(identifier)
)
)
)
)
)
)
)
=========================
Simple Declaration (int)
=========================
parser simple() {
state start {
int l;
transition accept;
}
};
---
(p4program
(declaration
(parserDeclaration
(parserType
(parser)
(identifier)
)
(parserStates
(parserState
(state)
(identifier)
(parserLocalElements
(parserLocalElement
(variableDeclaration
(typeRef
(baseType
(int)
)
)
(identifier)
)
)
)
(parserTransitionStatement
(transition)
(transitionSelectionExpression
(identifier)
)
)
)
)
)
)
)
=========================
Simple Declaration (string)
=========================
parser simple() {
state start {
string l;
transition accept;
}
};
---
(p4program
(declaration
(parserDeclaration
(parserType
(parser)
(identifier)
)
(parserStates
(parserState
(state)
(identifier)
(parserLocalElements
(parserLocalElement
(variableDeclaration
(typeRef
(baseType
(string)
)
)
(identifier)
)
)
)
(parserTransitionStatement
(transition)
(transitionSelectionExpression
(identifier)
)
)
)
)
)
)
)
=========================
Simple Declaration (string with initial value)
=========================
parser simple() {
state start {
string l = "testing";
transition accept;
}
};
---
(p4program
(declaration
(parserDeclaration
(parserType
(parser)
(identifier)
)
(parserStates
(parserState
(state)
(identifier)
(parserLocalElements
(parserLocalElement
(variableDeclaration
(typeRef
(baseType
(string)
)
)
(identifier)
(assignment)
(expression
(string_literal)
)
)
)
)
(parserTransitionStatement
(transition)
(transitionSelectionExpression
(identifier)
)
)
)
)
)
)
)