#
# NBS Template
#

# definition of tokens
TOKEN:keyword:( "instanceof" | "this" | "null" | "true" | "false" | "new")
TOKEN:invalid_keyword:( "if" | "while" | "for" | "else" | "do")
TOKEN:operator: (
    "==" | "!=" | "<<" | ">>" | ">>>" | ">=" | "<=" | "++" | "--" | 
    "+=" | "-=" | "*=" | "/=" | "%=" | "<<=" | ">>=" | ">>>=" | "&=" | 
    "^=" | "|=" | "&&" | "||" | "===" | "!==" | 
    "?" | ":" | "<" | ">" | "*" | "-" | "+" | "." | "," | "=" |
     "(" | ")" | "[" | "]" | "!" | "@" | "#" | "%" | "^" | "&" | 
    "~" | "|" | "\\" | "."
)

TOKEN:whitespace:( [" " "\t" "\n" "\r"]+ )

TOKEN:identifier: ( ["a"-"z" "A"-"Z" "_"]["a"-"z" "A"-"Z" "0"-"9" "_" "$"]*)

#TOKEN:object_start: ( "$F{" | "$V{" | "$P{" )



#TOKEN:object_F: ( ("$F{")([^"\n" "\r"])*["}"] )
#TOKEN:object_V: ( ("$V{")([^"\n" "\r"])*["}"] )

TOKEN:object_R: ( ("$R{")([^"\n" "\r"])*["}"] )

TOKEN:object_F: {
    call: com.jaspersoft.ireport.designer.editor.ExpObjectLexerSupport.parseExpObject;
}

TOKEN:object_V: {
    call: com.jaspersoft.ireport.designer.editor.ExpObjectLexerSupport.parseExpObject;
}

TOKEN:object_P: {
    call: com.jaspersoft.ireport.designer.editor.ExpObjectLexerSupport.parseExpObject;
}



TOKEN:invalid_object: {
    call: com.jaspersoft.ireport.designer.editor.ExpObjectLexerSupport.parseExpObject;
}


#TOKEN:method:( ["."]["a"-"z" "A"-"Z" "_"] 
#    ["a"-"z" "A"-"Z" "0"-"9" "_" "$"
#    ]* ):<BEFORE_PAR>
#
#<BEFORE_PAR> {
#    TOKEN:operator:( "(" ):<DEFAULT>
#}


TOKEN:number: (
    ["0"-"9"] ['l' 'L']? |
    ["1"-"9"] ["0"-"9"]* ['l' 'L']? |
    "0" ["0"-"7"]+ ['l' 'L']? |
    "0" ["x" "X"] ["0"-"9" "a"-"f" "A"-"F"]+ ['l' 'L']? |
    ["0"-"9"]+ "." ["0"-"9"]* (["e" "E"] ["+" "-"]? ["0"-"9"]+)? ["f" "F" "d" "D"]? |
    "." ["0"-"9"]+ (["e" "E"] ["+" "-"]? ["0"-"9"]+)? ["f" "F" "d" "D"]? |
    ["0"-"9"]+ ["e" "E"] ["+" "-"]? ["0"-"9"]+ ["f" "F" "d" "D"]? |
    ["0"-"9"]+ (["e" "E"] ["+" "-"]? ["0"-"9"]+)? ["f" "F" "d" "D"]
)

TOKEN:string: (
    "\"" ( 
        [^ "\\" "\"" "\n" "\r"] |
        ("\\" (
            . |
            (["0"-"7"] ["0"-"7"] ["0"-"7"]) |
            ("x" ["0"-"9" "a"-"f" "A"-"F"] ["0"-"9" "a"-"f" "A"-"F"]) |
            ("u" ["0"-"9" "a"-"f" "A"-"F"] ["0"-"9" "a"-"f" "A"-"F"] ["0"-"9" "a"-"f" "A"-"F"] ["0"-"9" "a"-"f" "A"-"F"])
        ))
    )* 
    "\""
)

TOKEN:char: (
    "\'"
	( [^"\'" "\n" "\r"] |
	  ("\\" ["r" "n" "t" "\\" "\'" "\""])
	)
    "\'"
)




COLOR:keyword: {
    foreground_color: "0x0000e6";
}

#COLOR:method: {
#    foreground_color: "0x000000";
#    font_type: "bold";
#}

COLOR:object_V: {
    foreground_color: "0x0000FF";
    font_type: "bold";
}

COLOR:object_F: {
    foreground_color: "0x00b200";
    font_type: "bold";
}

COLOR:object_P: {
    foreground_color: "0xb20000";
    font_type: "bold";
}

COLOR:object_R: {
    foreground_color: "0xce7b66";
    font_type: "bold";
}

COLOR:invalid_object: {
    foreground_color: "0xec2d2d";
    font_type: "bold";
}

COLOR:string: {
    foreground_color: "0xce7b66";
}

COLOR:invalid_keyword: {
    strike_through_color: "0x770000";
}





# code folding
FOLD:Block

# navigator support
#NAVIGATOR:WhileStatement: {
#    display_name: "$ConditionalExpression$";
#}

# brace completion
COMPLETE "{:}"
COMPLETE "(:)"

# brace matching
BRACE "{:}"
BRACE "(:)"

# indentation support
INDENT "{:}"
INDENT "(:)"
INDENT "\\s*(((if|while)\\s*\\(|else\\s*|else\\s+if\\s*\\(|for\\s*\\(.*\\))[^{;]*)"

# error highlighting
MARK:ERROR: {
    type:"Error";
    message:"Syntax error.";
}
MARK:error: {
    type:"Error";
    message:"Unexpected character.";
}


# code completion
#
COMPLETION: object_invalid, keyword, invalid_keyword, error, object_V, object_P, object_F, whitespace, identifier, operator  : {
    text1:com.jaspersoft.ireport.designer.editor.JRSyntaxSupport.completionItems;
}



