expected constructor, destructor, or type conversion before '(' token

int duration, distance; digitalWrite(trigPin,HIGH); delayMicroseconds(1000); digitalWrite(trigPin,LOW); duration = pulseIn(echoPin,HIGH); distance = (duration/2)/29.1;

what am I doing wrong?

You haven't posted complete code and you aren't using code tags. That's what you've done wrong. As for the cause of the error it is impossible to say from only that snippet.

You have to put code INSIDE a function. Outside of functions the only thing you can do is declare global variables. "digitalWrite" is not a variable declaration.

sketch_apr29b:2: error: expected constructor, destructor, or type conversion before '(' token
 digitalWrite(trigPin, HIGH);
             ^
sketch_apr29b:3: error: expected constructor, destructor, or type conversion before '(' token
 delayMicroseconds(1000);
                  ^
sketch_apr29b:4: error: expected constructor, destructor, or type conversion before '(' token
 digitalWrite(trigPin, LOW);
             ^
sketch_apr29b:5: error: 'duration' does not name a type
 duration = pulseIn(echoPin, HIGH);
 ^
sketch_apr29b:6: error: 'distance' does not name a type
 distance = (duration / 2) / 29.1;
 ^
exit status 1
expected constructor, destructor, or type conversion before '(' token

Once you put your code inside a function you will find that you forgot to define 'trigPin' and 'echoPin'.

void setup() {
  int duration, distance;
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration / 2) / 29.1;
}
void loop() {}
/Users/john/Documents/Arduino/sketch_apr29b/sketch_apr29b.ino: In function 'void setup()':
sketch_apr29b:3: error: 'trigPin' was not declared in this scope
   digitalWrite(trigPin, HIGH);
                ^
sketch_apr29b:6: error: 'echoPin' was not declared in this scope
   duration = pulseIn(echoPin, HIGH);
                      ^
exit status 1
'trigPin' was not declared in this scope

Thank you