mcc-mc.opp.exp 2.91 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
File "mcc-mc.mly", line 50, characters 27-36:
Warning: the token TokDQuote is unused.
File "mcc-mc.mly", line 58, characters 27-41:
Warning: the token TokEndLanguage is unused.
File "mcc-mc.mly", line 63, characters 43-48:
Warning: the token TokId is unused.
%{
open Fc_parse_type
open Fc_frontends

let parse_pascal buffer =
    FrontEnd.set_pascal_parsing ();
    Fc_parse_state.init_types ();
    let elist = Pasqual_parser.bootstrap Pasqual_lexer.main (Lexing.from_string buffer) in
	[PascalExpr (Fc_parse_state.current_position (), elist)]

let parse_pasqual buffer =
    FrontEnd.set_pasqual_parsing ();
    Fc_parse_state.init_types ();
    Pasqual_parser.bootstrap Pasqual_lexer.main (Lexing.from_string buffer)

let parse_fc buffer =
    FrontEnd.set_parameter_copying CopyNone;
    Fc_parse_state.init_types ();
    Fc_parse.prog Fc_lex.main (Lexing.from_string buffer)

%}
%start program
%token <string * Fc_parse_type.pos> TokString
%token <string * Fc_parse_type.pos> TokSourceString
%token <Fc_parse_type.pos> TokSource
%token <Fc_parse_type.pos> TokPasqual
%token <Fc_parse_type.pos> TokPascal
%token <Fc_parse_type.pos> TokLt
%token <Fc_parse_type.pos> TokLanguage
%token <Symbol.symbol * Fc_parse_type.pos> TokId
%token <Fc_parse_type.pos> TokGt
%token <Fc_parse_type.pos> TokFC
%token <Fc_parse_type.pos> TokEq
%token TokEof
%token <Fc_parse_type.pos> TokEndLanguage
%token <Fc_parse_type.pos> TokDQuote

%type <Fc_parse_type.expr list> program
%%

program:
48 49 50 51 52 53
| _1 = source_block_list _2 = TokEof
    {                               ( _1 )}
| _1 = source_block_list
    {                         ( _1 )}
| _1 = TokEof
    {               ( [] )}
54 55

source_block_list:
56 57 58 59
| _1 = source_block_list _2 = source_block
    {        ( _1 @ _2 )}
| _1 = source_block
    {                    ( _1 )}
60 61

source_block:
62 63 64 65 66 67 68 69
| _1 = pascal_block
    {                    ( _1 )}
| _1 = pasqual_block
    {                     ( _1 )}
| _1 = fc_block
    {                 ( _1 )}
| _1 = generic_block
    {                     ( _1 )}
70 71

pascal_block:
72 73
| _1 = TokLt _2 = TokLanguage _3 = TokEq _4 = TokPascal _5 = TokSource _6 = TokEq _7 = TokSourceString _8 = TokGt
    {        ( parse_pascal (fst _7) )}
74 75

pasqual_block:
76 77
| _1 = TokLt _2 = TokLanguage _3 = TokEq _4 = TokPasqual _5 = TokSource _6 = TokEq _7 = TokSourceString _8 = TokGt
    {    ( parse_pasqual (fst _7) )}
78 79

fc_block:
80 81
| _1 = TokLt _2 = TokLanguage _3 = TokEq _4 = TokFC _5 = TokSource _6 = TokEq _7 = TokSourceString _8 = TokGt
    {    ( parse_fc (fst _7) )}
82 83

generic_block:
84 85
| _1 = TokLt _2 = TokLanguage _3 = TokEq _4 = TokString _5 = TokSource _6 = TokEq _7 = TokSourceString _8 = TokGt
    {        ( match String.lowercase (fst _4) with
86
				      "pascal" ->
87
					parse_pascal (fst _7)
88
				    | "pasqual" ->
89
					parse_pasqual (fst _7)
90
				    | "c" | "fc" ->
91
					parse_fc (fst _7)
92
				    | _ ->
93
					print_string ("warning: block ignored (no front-end is found for " ^ (fst _4) ^ ")\n");
94
					[]
95
				)}
96 97 98 99 100

%%