Class ParserAttribute


  • public class ParserAttribute
    extends java.lang.Object
    Attributes that can be associated with a symbol or token.

    ParserAttributes are a way to associate arbitrary additional information with the symbols in the grammar or the tokens in the input. For example, to associate additional metadata with nonterminals or to associate line and column numbers with tokens.

    It's worth observing that the terminals created from the input stream don't get metadata.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String COLUMN_NUMBER_NAME
      the name of column number attributes.
      static java.lang.String LINE_NUMBER_NAME
      The name of line number attributes.
      static java.lang.String OFFSET_NAME
      The name of offset attributes.
      static java.lang.String REGEX_NAME
      The name of regular expression attributes.
    • Constructor Summary

      Constructors 
      Constructor Description
      ParserAttribute​(java.lang.String name, java.lang.String value)
      Create a parser attribute.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      java.lang.String getName()
      Get the name of an attribute.
      java.lang.String getValue()
      Get the value of an attribute.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • LINE_NUMBER_NAME

        public static final java.lang.String LINE_NUMBER_NAME
        The name of line number attributes.
        See Also:
        Constant Field Values
      • COLUMN_NUMBER_NAME

        public static final java.lang.String COLUMN_NUMBER_NAME
        the name of column number attributes.
        See Also:
        Constant Field Values
      • OFFSET_NAME

        public static final java.lang.String OFFSET_NAME
        The name of offset attributes.
        See Also:
        Constant Field Values
      • REGEX_NAME

        public static final java.lang.String REGEX_NAME
        The name of regular expression attributes.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ParserAttribute

        public ParserAttribute​(java.lang.String name,
                               java.lang.String value)
        Create a parser attribute.
        Parameters:
        name - the attribute name
        value - the attribute value
        Throws:
        java.lang.NullPointerException - if the name or value are null
    • Method Detail

      • getName

        public java.lang.String getName()
        Get the name of an attribute.
        Returns:
        the attribute name
      • getValue

        public java.lang.String getValue()
        Get the value of an attribute.
        Returns:
        the attribute value
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object