0 Votes

Lisp Syntax

Last modified by WikiBot on 2025/03/20 14:15

Lisp Syntax

The Lisp code is a sequence of items. An item is one of the following:

  • A sequence of non-special characters (treated as a number or a symbol). The sequence is terminated by blank space or some special character except \, |, and #.
  • A sequence of characters starting with a special character. The end of the sequence and the interpretation vary depending on the special character.

Here is the list of Lisp special characters used in IDA:

   
( list A sequence of items enclosed in matching parentheses is treated as a list;
" string A sequence of characters (even special) enclosed in double quotes is treated as a string;
; comment All subsequent characters in this line are ignored;
' quote ‘item is treated as a list (QUOTE item);
\ single escape The next character is treated as non-special (even inside strings enclosed in double quotes);
 multiple escape The following characters up to the next  are treated as non-special;
# dispatch Treated as special only if it starts an item. The meaning depends on the next character (with possible numerical parameter between # and that character);
#( vector A sequence of items enclosed in matching parentheses is treated as a 1-dimensional array;
#nA array #nA( … ) is treated as an n-dimensional array. The list in parentheses should be nested n times. The default value of n is 1;
#X hex An integer number in hexadecimal format;
#S structure #S(name field value field value …) is treated as a Lisp structure with given name and field values;
#\ character #\c is treated as character c. #\Name is treated as the named character. The named characters are Backspace, Tab, Linefeed, Page, Newline (alias Return), Escape, Delete (alias Rubout), and Control-A, …, Control-Z.
#comment All text till # is ignored.

Here are IDA extensions to Lisp syntax:

   
[ bracket This special character is reserved for Lisp users. IDA Modeler treats a sequence of items enclosed in matching brackets as a reference to object;
{ brace This character is treated as special in IDA though it is not special in Lisp. IDA Modeler treats a sequence of items {item1 … } enclosed in matching braces as a list (:vector item1 … ). When used in a script expression, this list is evaluated to a vector.

The special characters ` (back quote) and , (comma) are not used in IDA Modeler and treated as illegal. The closing parenthesis, bracket, and brace are also treated as special; they are illegal unless they match the opening ones.