2.5.1 Formula ABNF and Full Grammar Definition

A formula expression MUST conform to the following ABNF [RFC5234] grammar.

  
 val = func / token / ref
 val /= "(" val ")"      ; Enclose an expression in parens for higher precedence
 func = Abs / ACos / Add / And / Ang360 / AngleToLoc / AngleToPar / ASin / ATan / ATan2 / BitAnd / BitNot / BitOr / BitXor / BkgPageName / Blend / Bound / Cat / Category / Ceiling / CellIsThemed / Char / Company / Cos / CosH / Creator / CY / Date / DateTime / DateValue / Day / DayOfYear / Deg / DependsOn / Description / Directory / Div / DocCreation / DocLastEdit / DocLastPrint / DocLastSave / EEQ / EGE / EGT / ELE / ELT / ENE / FEQ / FGE / FGT / FieldPicture / FileName / Find / FLE / Floor / FLT / FNE / Format / FormatEx / FormulaExists / Gravity / Guard / HasCategory / Hour / HSL / Hue / HueDiff / HyperlinkBase / ID / IF / IfError / Index / Int / IntersectX / IntersectY / Intup / Is1D / IsErr / IsErrNA / IsError / IsErrValue / IsThemed / Keywords / Language / Left / Len / Ln / Loc / LocalFormulaExists / LocToLoc / LocToPar / Log10 / Lookup / Lower / Lum / LumDiff / Magnitude / Manager / MasterName / Max / Mid / Min / Minute / Modulus / Month / MsoShade / MsoTint / Mul / NA / Name / Not / Now / Nurbs / Or / PageCount / PageName / PageNumber / Par / Pct / Pi / Pnt / Pntx / PntY / PolyLine / Pow / Rad / Rand / Ref / Replace / RGB / Right / Round / Sat / SatDiff / Second / SetAtRef / SetAtRefEval / SetAtRefExpr / Shade / ShapeText / Sign / Sin / SinH / Sqrt / StrSame / StrSameEx / Sub / Subject / Substitute / Sum / Tan / TanH / TextHeight / TextWidth / Theme / ThemeCBV / ThemeGuard / ThemeProp / ThemeRestore / ThemeVal / Time / TimeValue / Tint / Title / Tone / Trim / Trunc / UMinus / UniChar / UPlus / Upper / Use / Version / WeekDay / Year / functiondef
 functiondef = ALPHA *(ALPHA / DIGIT / "_") "(" [val *("," val)] ")"
 token = PtgAcre / PtgAngDD / PtgAngDft / PtgAngDMS / PtgAngRad / PtgBool / PtgByte / PtgColorRGB / PtgCy / PtgDate / PtgEDay / PtgEHour / PtgEMin / PtgErr / PtgESec / PtgEWeek / PtgHectare / PtgInt / PtgNum / PtgNumCM / PtgNumDft / PtgNumF / PtgNumFI / PtgNumI / PtgNumKM / PtgNumM / PtgNumMI / PtgNumMM / PtgNumMultiDim / PtgNumNM / PtgNumPct / PtgNumYards / PtgNurbs / PtgPageDft / PtgPnt / PtgPolyLine / PtgShort / PtgString / PtgTDurDft / PtgTypCD / PtgTypCi / PtgTypDft / PtgTypDi / PtgTypPi / PtgTypPP / PtgTypPt / PtgUnsShort
 ref           = [sheetref "!"] CellRef
 sheetref       = CrossPageRef / DocSheetRef / MasterSheetRef / PageSheetRef / ShapeSheetRef / StyleSheetRef
 name          = 1*(ALPHA / DIGIT / "_")
 nameid          = "'" name "'" / name ["." 1*DIGIT]
 id          = 1*DIGIT
 color-value        = "#" 6HEXDIG
 dimension        = unsigned-int-value
 int-value       = ["+" / "-"] 1*DIGIT
 short-value       = ["+" / "-"] 1*DIGIT
 unsigned-int-value     = ["+"] 1*DIGIT
 unsigned-byte-value    = ["+"] 1*DIGIT
 double-value        = ["+" / "-"] (*DIGIT ["."] 1*DIGIT / 1*DIGIT ".")
                        ["e" ["+" / "-"] 1*DIGIT]
 bool-value        = ("true" / "1") / ("false" / "0")
 string-value       = *utf8-char               ; [RFC3629] UTF-8 strings
 utf8-char       = ascii-char / utf8-non-ascii-chars
 ascii-char       = HTAB / LF / CR / SP / VCHAR   ; Whitespace and printing chars
 utf8-non-ascii-chars = (%xC0-DF 1utf8-content) /
                        (%xE0-EF 2utf8-content) /
                        (%xF0-F7 3utf8-content) /
                        (%xF8-FB 4utf8-content) /
                        (%xFC-FD 5utf8-content)
 utf8-content       = %x80-BF