Changeset 3895 for applications/trunk


Ignore:
Timestamp:
Sep 2, 2008, 4:54:12 PM (12 years ago)
Author:
orlov
Message:
  • Some progress in the LFC implementation through ASR.
Location:
applications/trunk/LFC
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/trunk/LFC/Earley/Earley.rf

    r3893 r3895  
    8787Main =
    8888  <Init (PROD (TYPE ('E')) ((TYPE ('E')) '+' (TYPE ('E'))) ('n'))>,
    89   <Check (TYPE ('E'))/* '+' (TYPE ('E'))*/ ('n+n')>,
     89  <Check (TYPE ('E')) ('n+n')>,
     90  <PrintLn>,
     91  <Check (TYPE ('E')) ('n+n+n')>,
    9092  <PrintLn>,
    9193  <Init (PROD (TYPE ('S')) ((TYPE ('A')) (TYPE ('A')) (TYPE ('A')) (TYPE ('A'))))
    9294        (PROD (TYPE ('A')) ('a') ((TYPE ('E'))))
    9395        (PROD (TYPE ('E')) ())>,
    94   <Check (TYPE ('S')) ('a')>;
     96  <Check (TYPE ('S')) ('a')>,
     97  <PrintLn>,
     98  <Init (PROD (TYPE ('T')) ((TYPE ('A'))) ((TYPE ('B'))))
     99        (PROD (TYPE ('A')) ('x'))
     100        (PROD (TYPE ('B')) ('x'))>,
     101  <Check (TYPE ('T')) ('x')>;
  • applications/trunk/LFC/ToASR/ToASR.rf

    r3893 r3895  
    2929$func CallEarley t.var = e.call;
    3030CallEarley (EVAR (s.n e.name)) =
    31   (RESULT (CALL (Earley Earley) (TYPE (e.name)) (EVAR (s.n e.name))))
     31  (RESULT (CALL (Earley Earley) (PAREN TYPE (PAREN e.name)) (EVAR (s.n e.name))))
    3232  (FORMAT (EVAR (s.n)));
    3333
     
    4343  <L s.n e.args> : (EVAR (s.n e.type_name)),
    4444  (RESULT (EVAR (s.n)))
    45   (LEFT <FreshEVAR> ((TYPE (e.type_name) (EVAR (0 s.n))) <Map &VarType (e.var_decls) (e.pattern)> DOT 0) <FreshEVAR>)
     45  (LEFT <FreshEVAR> (PAREN (PAREN TYPE (PAREN e.type_name) (EVAR (0 s.n))) <Map &VarType (e.var_decls) (e.pattern)> DOT 0) <FreshEVAR>)
    4646  (RESULT (CALL (Earley RemoveParens) (EVAR (0 s.n))))
    4747  (LEFT <Map &GetVar (e.pattern)>);
     
    5050VarType (e.var_decls) t.pat, {
    5151  t.pat : (VAR t.name) =
    52     e.var_decls : e (e t.pat e t.type) e = t.type;
     52    e.var_decls : e (e t.pat e (TYPE (e.type_name))) e = (PAREN TYPE (PAREN e.type_name));
    5353  t.pat;
    5454};
     
    9393  ));
    9494
     95$func AddPAREN e = e;
     96AddPAREN {
     97  (e1) e2 = (PAREN <AddPAREN e1>) <AddPAREN e2>;
     98  s1 e2 = s1 <AddPAREN e2>;
     99  /*empty*/ = /*empty*/;
     100};
     101
    95102$box ModuleName;
    96103
     
    101108Main =
    102109  <ParseFile "samples.lfc"> :: e.ast,
    103   <ParseGrammarFile "samples.g"> :: e.grammar,
     110  <AddPAREN <ParseGrammarFile "samples.g">> :: e.grammar,
    104111  <Store &ModuleName "samples">,
    105   <WriteLn (MODULE (<Get &ModuleName>) <Comp e.ast> <GenerMain ('isBit') e.grammar>)>;
     112  (IMPORT FUNC ("refal" "plus" StdIO WriteLn) ((EVAR)) ())
     113  (IMPORT FUNC (Earley Init) ((EVAR)) ())
     114  (IMPORT FUNC (Earley RemoveParens) ((EVAR)) ((EVAR)))
     115  (IMPORT FUNC (Earley Earley) ((TVAR) (EVAR)) ((EVAR))) :: e.imports,
     116  <Channel> :: s.ch,
     117  <OpenFile s.ch "samples.asr" W>,
     118  <WriteLnCh s.ch (MODULE (<Get &ModuleName>) e.imports <Comp e.ast> <GenerMain ('isBit') e.grammar>)>,
     119  <CloseChannel s.ch>;
  • applications/trunk/LFC/parser/Parser.rf

    r3893 r3895  
    99  <Lexer <File_Open e.fname>> :: e.tokens,
    1010  //<WriteLn e.tokens>,
    11   <GetRAST <Program e.tokens>>;
     11  <GetRAST <Program e.tokens>> : e.ast (),
     12  e.ast;
    1213
    1314$public $func GetRAST e.ast = e.ast;
Note: See TracChangeset for help on using the changeset viewer.