# Modifying a ParserState Node

**URL:** <https://forum.p4.org/t/modifying-a-parserstate-node/562>\
**Category:** Language Design Working Group\
**Created:** [December 4, 2022, 12:44am UTC](https://forum.p4.org/t/modifying-a-parserstate-node/562 "2022-12-04T00:44:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohxen](https://avatars.discourse-cdn.com/v4/letter/m/6de8d8/32.png) [@mohxen](https://forum.p4.org/u/mohxen)\
**Post date:** [December 4, 2022, 12:44am UTC](https://forum.p4.org/t/modifying-a-parserstate-node/562/1 "2022-12-04T00:44:26Z")

</div>

Hi all,

I want to modify a ParserState node in a new pass in frontend. I used preorder in IR::ParserState by using Transform. For example, for one node I have  
state parse\_udp { packet.extract\<udp\_t\>(hdr.udp); accept;}  
and I want to change it to  
state parse\_tcp {packet.extract\<tcp\_t\>(hdr.tcp); accept;}  
so I checked ParserState class, we have node-\>name which is parse\_udp in my example and I try to change it to parse\_tcp by  
node-\>name = new IR::ParserValueSet::ID (“parse\_tcp”); or  
node-\>name = new IR::ID(“parse\_tcp”);  
But I have some errors. Could you give me some hints?  
Also, in ParserState class I could not find any methods or variables related to packet.extract\<udp\_t\>(hdr.udp). please let me know how I can access to that.

---

<div class="post-metadata">

**Author:** ![andyfingerhut](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.p4.org/andyfingerhut/32/17_2.png) [@andyfingerhut](https://forum.p4.org/u/andyfingerhut)\
**Post date:** [December 4, 2022, 1:56am UTC](https://forum.p4.org/t/modifying-a-parserstate-node/562/2 "2022-12-04T01:56:15Z")

</div>

This sounds like you are asking about internals of the open source p4c compiler implementation, and how to change them. I suspect that creating an issue on the repository [GitHub - p4lang/p4c: P4\_16 reference compiler](https://github.com/p4lang/p4c) is a better way to get attention from p4c developers on such questions, rather than asking here.

---

<div class="post-metadata">

**Author:** ![mohxen](https://avatars.discourse-cdn.com/v4/letter/m/6de8d8/32.png) [@mohxen](https://forum.p4.org/u/mohxen)\
**Post date:** [December 4, 2022, 2:08am UTC](https://forum.p4.org/t/modifying-a-parserstate-node/562/3 "2022-12-04T02:08:06Z")

</div>

Thank you, I created an issue.
