001/* 002 * To change this license header, choose License Headers in Project Properties. 003 * To change this template file, choose Tools | Templates 004 * and open the template in the editor. 005 */ 006package org.anarres.cpp; 007 008import javax.annotation.CheckForNull; 009import javax.annotation.Nonnull; 010 011/** 012 * 013 * @author shevek 014 */ 015public enum PreprocessorCommand { 016 017 PP_DEFINE("define"), 018 PP_ELIF("elif"), 019 PP_ELSE("else"), 020 PP_ENDIF("endif"), 021 PP_ERROR("error"), 022 PP_IF("if"), 023 PP_IFDEF("ifdef"), 024 PP_IFNDEF("ifndef"), 025 PP_INCLUDE("include"), 026 PP_LINE("line"), 027 PP_PRAGMA("pragma"), 028 PP_UNDEF("undef"), 029 PP_WARNING("warning"), 030 PP_INCLUDE_NEXT("include_next"), 031 PP_IMPORT("import"); 032 private final String text; 033 /* pp */ PreprocessorCommand(String text) { 034 this.text = text; 035 } 036 037 @CheckForNull 038 public static PreprocessorCommand forText(@Nonnull String text) { 039 for (PreprocessorCommand ppcmd : PreprocessorCommand.values()) 040 if (ppcmd.text.equals(text)) 041 return ppcmd; 042 return null; 043 } 044}