表达式的EBNF
  〈表达式〉∷=[+|-]〈项〉{(+|-)〈项〉}
  〈项〉∷=〈因子〉{(*|/)〈因子〉}
  〈因子〉∷=〈标识符〉|〈无符号整数〉|‘(’〈表达式〉‘)’
  〈表达式〉的递归子程序实现
程序段   procedure expr;
   begin
    if sym in [ plus, minus ] then
     begin
      getsym; term;
     end
    else term;
    while sym in [plus, minus] do
     begin
      getsym; term;
     end
   end;
  〈项〉的递归子程序实现
程序段   procedure term;
  begin
   factor;
   while sym in [ times, slash ] do
   begin
    getsym; factor;
   end
  end;

  〈因子〉的递归子程序实现
程序段   procedure factor;
  begin
   if sym <> ident then
    begin
     if sym <> number then
      begin
       if sym = ‘(‘ then
        begin
         getsym;
         expr;
         if sym = ‘)’ then
          getsym
         else error
        end
       else error
      end
    end
  end;

  语法分析程序除总控外主要有两大部分的功能,即对说明部分的处理和对程序体部分的处理,也就是在语法单元中的分程序功能。在PL/0编译程序中对应的过程为BLOCK,其流程图如图2.8所示。
图 2.8 程序BLOCK过程的流程图