Method: Crokus::Parser#declaration

Defined in:
lib/crokus/parser.rb

#declarationObject

int a int * a int a=1,b=2; int a[] int* f() struct name *ptr; paire_t paire = 1,2; int a,b,*c


TYPE ident ident ident



389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# File 'lib/crokus/parser.rb', line 389

def declaration
  ret=[]
  @current_type=type=parse_type()
  d=declarator()
  a=arrayed?(type)
  if a
    type=a
  end
  func=parenthesized?
  if func
    func.type=type
    ret << func #func
    return ret
  end
  init=initialization?
  ret << Decl.new(type,d,init)
  while tokens.any? and showNext.is?(:comma)
    acceptIt
    ptr=pointed?
    if ptr
      type2=PointerTo.new(type)
    end
    d2=declarator
    a2=arrayed?(type)
    i2=initialization?
    ret << Decl.new(type2||type,d2)
  end
  if tokens.any?
    maybe :semicolon
  end
  return ret
end