Class Util

  extended bybyucc.jhdl.base.Util

public class Util
extends java.lang.Object

A set of utility routines.

Brad L. Hutchings

Constructor Summary
Method Summary
static boolean isLegalJHDLIdentifier(java.lang.String str)
          Used to check if an identifier is a legal JHDL user identifier.
static java.lang.String makeLegalJHDLIdentifier(java.lang.String str)
          Converts an arbitrary string into a legal JHDL name.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public Util()
Method Detail


public static boolean isLegalJHDLIdentifier(java.lang.String str)
Used to check if an identifier is a legal JHDL user identifier. This method only accepts identifiers with a leading letter, followed by any number of alphanumeric characters and non-consecutive underscores (_). JHDL defaults to case-sensitivity, but that can be changed with Nameable.caseSensitivity(boolean). JHDL names accept Unicode.

str - the string being checked.
true if name is a legal user identifier, false otherwise.


public static java.lang.String makeLegalJHDLIdentifier(java.lang.String str)
Converts an arbitrary string into a legal JHDL name. The resulting string begins with a letter, and contains only alphanumeric characters and non-consecutive underscores (_). This method supports Unicode strings.

The conversion rules are as follows: Any character that is not alphanumeric is replaced by an underscore (_). Consecutive underscores are reduced to a single underscore. If the resulting string begins with an underscore followed by a letter, the leading underscore is removed. In all other cases where the result does not begin with a letter, the string "jhdl_" is prepended to the result. Case sensitivity is preserved.

Examples: "My name-1" becomes "My_name_1", "__test__" becomes "test_", null becomes "jhdl_", and "1hot/control.bit[1]" becomes "jhdl_1hot_control_bit_1_".

str - the string to be converted
a valid JHDL name, converted from str according to the description

Copyright ? 2006 Brigham Young University, Configurable Computing Laboratory. All Rights Reserved.