To diagram sentences with linear Phrase Structure rules instead of tree diagrams, follow this basic primer on how to do so.
Given the sentence, Mary had a little lamb from left to right, the sentence is indicated by the node S.
A right arrow, using the greater than symbol (>), is placed immediately after the S, to indicate that the elements that followed are constituents of the S.
Where S is Mary had a little lamb;
Noun phrase (NP) is the subject Mary;
Verb phrase (VP) is the predicate had a little lamb.
This would be represented as: S > NP VP
Leave a space between each node.
Next, we break down each constituent further
NP consists of a single noun (N)
This would be represented in the next line as: NP > N
The noun in the subject is Mary
This would be represented in the next line as: N > Mary
Next is a VP consisting of a verb (V) and another noun phrase (NP)
This would be represented in the next line as: VP > V NP
The verb (V) in the VP is had and would be represented as: V > had
The NP in the VP is a little lamb and consists of a determiner (DET) and a smaller NP.
This would be represented in the next line as: NP > DET NP
The DET in the sentence is a
The DET would be represented in the next line as: DET > a
The smaller NP consists of the Adjective Phrase (AdjP) and noun (N)
This would be represented in the next line as: NP > AdjP N
The AdjP consists of a single adjective (ADJ)
This would be represented in the next line as: AdjP > ADJ
The ADJ is little
This would be represented in the next line as: ADJ > little
Last, the noun is lamb and would be represented in the final line as: N > lamb
The final solution for the sentence, Mary had a little lamb, would be:
S > NP VP
NP > N
N > Mary
VP > V NP
V > had
NP > DET NP
DET > a
NP > AdjP N
AdjP > ADJ
ADJ > little
N > lamb
Follow the same rules for all phrases at all levels.