Package jflex.core

Class Action


  • public final class Action
    extends Object
    Encapsulates an action in the specification.

    It stores the Java code as String together with a priority (line number in the specification).

    Version:
    JFlex 1.8.1
    Author:
    Gerwin Klein
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int BACKWARD_ACTION
      Action of the backward pass for lookahead
      String content
      The Java code this Action represents
      static int FINITE_CHOICE
      Action of a lookahead expression r1/r2 with a finite choice of fixed lengths in r2
      static int FIXED_BASE
      Action of a lookahead expression r1/r2 with fixed length r1
      static int FIXED_LOOK
      Action of a lookahead expression r1/r2 with fixed length r2
      static int FORWARD_ACTION
      Action of the 2nd forward pass for lookahead
      static int GENERAL_LOOK
      Action of a general lookahead expression
      static int NORMAL
      A normal action
      int priority
      The priority (i.e.
    • Constructor Summary

      Constructors 
      Constructor Description
      Action​(int kind)
      Creates a new Action object of the specified kind.
      Action​(String content, int priority)
      Creates a new Action object with specified content and line number.
    • Field Detail

      • FIXED_BASE

        public static final int FIXED_BASE
        Action of a lookahead expression r1/r2 with fixed length r1
        See Also:
        Constant Field Values
      • FIXED_LOOK

        public static final int FIXED_LOOK
        Action of a lookahead expression r1/r2 with fixed length r2
        See Also:
        Constant Field Values
      • FINITE_CHOICE

        public static final int FINITE_CHOICE
        Action of a lookahead expression r1/r2 with a finite choice of fixed lengths in r2
        See Also:
        Constant Field Values
      • GENERAL_LOOK

        public static final int GENERAL_LOOK
        Action of a general lookahead expression
        See Also:
        Constant Field Values
      • FORWARD_ACTION

        public static final int FORWARD_ACTION
        Action of the 2nd forward pass for lookahead
        See Also:
        Constant Field Values
      • BACKWARD_ACTION

        public static final int BACKWARD_ACTION
        Action of the backward pass for lookahead
        See Also:
        Constant Field Values
      • content

        public final String content
        The Java code this Action represents
      • priority

        public final int priority
        The priority (i.e. line number in the specification) of this Action.
    • Constructor Detail

      • Action

        public Action​(String content,
                      int priority)
        Creates a new Action object with specified content and line number.
        Parameters:
        content - java code
        priority - line number
    • Method Detail

      • getHigherPriority

        public Action getHigherPriority​(Action other)
        Compares the priority value of this Action with the specified action.
        Parameters:
        other - the other Action to compare this Action with.
        Returns:
        this Action if it has higher priority - the specified one, if not.
      • isEquiv

        public boolean isEquiv​(Action a)
        Returns true iff the parameter is an Action with the same content as this one.
        Parameters:
        a - the object to compare this Action with
        Returns:
        true if the action strings are equal
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • isGenLookAction

        public boolean isGenLookAction()
        Return true iff this is action belongs to a general lookahead rule.
        Returns:
        true if this actions belongs to a general lookahead rule.
      • isEmittable

        public boolean isEmittable()
        Return true if code for this is action should be emitted, false if it is a BACK/FORWARD lookahead action.
        Returns:
        true if code should be emitted for this action.
      • lookAhead

        public int lookAhead()
        Return kind of lookahead.
        Returns:
        a int.
      • setLookAction

        public void setLookAction​(int kind,
                                  int data)
        Sets the lookahead kind and data for this action
        Parameters:
        kind - which kind of lookahead it is
        data - the length for fixed length lookaheads.
      • getLookLength

        public int getLookLength()
        The length of the lookahead or base if this is a fixed length lookahead action.
        Returns:
        a int.
      • getEntryState

        public int getEntryState()
        Return the corresponding entry state for the forward DFA (if this is a general lookahead expression)
        Returns:
        the forward DFA entry state (+1 is the backward DFA)
      • setEntryState

        public void setEntryState​(int entryState)
        Set the corresponding entry state for the forward DFA of this action (if this is a general lookahead expression)
        Parameters:
        entryState - a int.
      • copyChoice

        public Action copyChoice​(int length)
        copyChoice.
        Parameters:
        length - a int.
        Returns:
        a Action object.
      • lookString

        public String lookString()
        String representation of the lookahead kind of this action.
        Returns:
        the string representation