Recent

Author Topic: Unknown syntax error  (Read 1157 times)

Weeb mindset

  • New Member
  • *
  • Posts: 10
Unknown syntax error
« on: August 11, 2020, 05:16:40 am »
So for some reason the following declarations has syntax error
lazarus says :
Code: Pascal  [Select][+][-]
  1. score           : array [subject] of real;  
  2.  
have syntax error : ',' expected but ';' found

the whole declaration is here:
Code: Pascal  [Select][+][-]
  1. type
  2.     int_a       = array of integer;
  3.     user        = record                //user type for account, extension
  4.                    Username, Password : string;
  5.                   end;
  6.     menu_op_s   = string[50-12];  //s for string, word limit: 50-12 = 48, 50 for border length, 12 for fixed contect of each line, which is every character that's not an element of menu_op
  7.     subject     = (Chi,Eng,Math,Ls,m1_2,Phy,Chem,Bio,ICT,VA,CI,CHIS,Econ,BAFS,HIS,GEOG,ERS);
  8.     rule_t      = (CE_M3,c42x,M5,M6);
  9.     score_info_t= record
  10.                    subject_t       : array [subject] of boolean;        //thx 5.5 taking my whole day
  11.                    score           : array [subject] of real;
  12.                    subject_nx      : integer;
  13.                   end;
  14.     score_t     = record
  15.                    raw_scores         : array [1..100] of score_info_t;         //each prgramme have storage slot of 100 (for scores), raw score are scores that imposed weighting
  16.                    medium_rare_score  : array [1..100] of real;                 //readable score are weighted score
  17.                    done_score         : integer;                                //after comparasion, the final result is store here
  18.                    record_c           : integer;                                //current amount of record
  19.                   end;
  20.     basic_info_t= record
  21.                    code            : string[6];         //length 6 = AB****
  22.                    name            : string;
  23.                    weighting       : array [subject] of integer;
  24.                    rule            : rule_t;
  25.                    LQ,cutoff       : score_t;
  26.                   end;
  27.     programme_t = record
  28.                    basic_info      : array [1..500]  of basic_info_t;                 //  {{{{{{max programme expected : 500}}}}}}}
  29.                    prog_c          : integer;                                         //  {{{{{{Currenet programme amount}}}}}}}
  30.                    ready           : boolean;
  31.                   end;
  32.  
  33. const
  34.      Subject_count    = 17;                 //17 subject
  35.      extract_location = 'C:\Users\xdken\Downloads\ict sba\real program\outputs\';
  36.      acDB_location    = 'C:\Users\xdken\Downloads\ict sba\real program\inputs\userDB.csv';
  37.      p_r_location     = 'C:\Users\xdken\Downloads\ict sba\real program\inputs\past_records.csv';
  38.      p_s_location     = 'C:\Users\xdken\Downloads\ict sba\real program\inputs\scoring.csv';
  39.      p_r_t_x          = Subject_count;
  40.      p_r_t_y          = 1000;
  41.      p_s_t_x          = 2+Subject_count+1;  //code,name,16 subject,rule
  42.      p_s_t_y          = 1+500;      //1 row of items + programme amout (500 row)
  43.      acDBsize         = 500;                //size of account DB
  44.      menu_op_c        = 4;                  //c for count, 4 option in menu
  45.      menu_op          : array [1..menu_op_c] of menu_op_s = ('programme data process and extraction' ,'enquiry' ,'expected result setting', 'Exit');   //the name of options, additional option can be modified here
  46.  
  47. var
  48.   i,j,it1,jt1,c,ti1,ti2,ti3,spec_i  : integer;  //i,j,c : count,it,jt : temp_i/j hat, ti : temp_integer
  49.   tri1                              : real;
  50.   ts1,ts2,ts3                       : string;   //ts : temp_string
  51.   p_r,p_s,acdbt,extract             : text;     //tt : temp_text
  52.   error,choice,auth,bye             : boolean;
  53.   s_t_v                             : subject;   //subject type variable
  54.   p_r_t                             : array [1..p_r_t_y,1..p_r_t_x] of string;
  55.   p_s_t                             : array [1..p_s_t_y,1..p_s_t_x] of string;
  56.   acDB                              : array [1..acdbsize] of user;
  57.   progDB                            : programme_t;
  58.   subject_3_a                       : array [1..3] of integer;
  59.   subject_4_a                       : array [1..4] of integer;
  60.   subject_5_a                       : array [1..5] of integer;
  61.   subject_6_a                       : array [1..6] of integer;
  62.   subject_7_a                       : array [1..7] of integer;
  63.   ingredients                       : array [subject] of boolean;
  64.   dinner_recipie                    : rule_t;
  65.   t_string_prog_a                   : array [1..acDBsize] of string; //use to temply store progrmme names for searching
  66.  

#edit
for somehow, declaring rea, a real type before int_a would result the same error, i started to doubt if it is related to real.
« Last Edit: August 11, 2020, 05:20:44 am by Weeb mindset »

TRon

  • Hero Member
  • *****
  • Posts: 2435
Re: Unknown syntax error
« Reply #1 on: August 11, 2020, 06:29:28 am »
Hi Weeb mindset,

Your declarations are confusing to me as they do not follow to the usual way in which these declarations are done in Pascal.

That specific declaration compiles just fine for me, so a compilable example is required. The ',' expected suggest an error that originates from somewhere else, most probably before your score declaration.

Code: Pascal  [Select][+][-]
  1. program test;
  2.  
  3. {$MODE OBJFPC}{$H+}
  4.  
  5. type TSubject = (Chi,Eng,Math,Ls,m1_2,Phy,Chem,Bio,ICT,VA,CI,CHIS,Econ,BAFS,HIS,GEOG,ERS);
  6. var  Score : array [TSubject] of real;
  7.  
  8. begin
  9. end.
  10.  
Code: [Select]
fpc -V3.2.0 -glh "test.pas" (in directory: /home/tron/projects/test)
Free Pascal Compiler version 3.2.0 [2020/06/08] for arm
Copyright (c) 1993-2020 by Florian Klaempfl and others
Target OS: Linux for ARMHF
Compiling test.pas
test.pas(9,3) Note: Local variable "Score" not used
Linking test
12 lines compiled, 1.7 sec
1 note(s) issued
Compilation finished successfully.

Weeb mindset

  • New Member
  • *
  • Posts: 10
Re: Unknown syntax error
« Reply #2 on: August 11, 2020, 09:12:06 am »
Hi Weeb mindset,

Your declarations are confusing to me as they do not follow to the usual way in which these declarations are done in Pascal.

That specific declaration compiles just fine for me, so a compilable example is required. The ',' expected suggest an error that originates from somewhere else, most probably before your score declaration.

Code: Pascal  [Select][+][-]
  1. program test;
  2.  
  3. {$MODE OBJFPC}{$H+}
  4.  
  5. type TSubject = (Chi,Eng,Math,Ls,m1_2,Phy,Chem,Bio,ICT,VA,CI,CHIS,Econ,BAFS,HIS,GEOG,ERS);
  6. var  Score : array [TSubject] of real;
  7.  
  8. begin
  9. end.
  10.  
Code: [Select]
fpc -V3.2.0 -glh "test.pas" (in directory: /home/tron/projects/test)
Free Pascal Compiler version 3.2.0 [2020/06/08] for arm
Copyright (c) 1993-2020 by Florian Klaempfl and others
Target OS: Linux for ARMHF
Compiling test.pas
test.pas(9,3) Note: Local variable "Score" not used
Linking test
12 lines compiled, 1.7 sec
1 note(s) issued
Compilation finished successfully.

ok !

PascalDragon

  • Hero Member
  • *****
  • Posts: 5448
  • Compiler Developer
Re: Unknown syntax error
« Reply #3 on: August 11, 2020, 09:19:54 am »
So for some reason the following declarations has syntax error

Would you please provide a full example and not merely the declarations? As TRon said the declarations alone compile without problems (I even tested multiple compiler modes to be sure).

 

TinyPortal © 2005-2018