![]()  | 
  
    P4C
    
   The P4 Compiler 
   | 
 
#include <constantParsing.h>
Public Attributes | |
| unsigned | base | 
| An ignored prefix of the numeric constant (e.g. '0x').  | |
| bool | hasWidth | 
| The base in which the constant is expressed.  | |
| unsigned | skip | 
| Raw P4 text which was recognized as a numeric constant.  | |
| cstring | text | 
An unparsed numeric constant. We produce these as token values during lexing. The parser is responsible for actually interpreting the raw text as a numeric value and transforming it into an IR::Constant using parseConstant().
To illustrate how a numeric constant is represented using this struct, here is a breakdown of '16w0x12':
     ___
    /                                    ___
    |                                   /
    |   bitwidth (if @hasWidth)        |       16
    |                                   \___
    |
    |                                    ___
    |                                   /
    |   separator (if @hasWidth)       |       w
    |                                   \___
@text | | ___ | / | ignored prefix of length
| ___ | | ___ | / | numeric value in base @base | w | ___ ___
Simple numeric constants like '5' are specified by setting @hasWidth to false and providing a
| unsigned UnparsedConstant::base | 
An ignored prefix of the numeric constant (e.g. '0x').
| bool UnparsedConstant::hasWidth | 
The base in which the constant is expressed.
| unsigned UnparsedConstant::skip | 
Raw P4 text which was recognized as a numeric constant.
| cstring UnparsedConstant::text |