Changeset 458


Ignore:
Timestamp:
Jul 7, 2010 1:18:56 AM (14 years ago)
Author:
Anya Helene Bagge
Message:
  • Update syntax to be in line with the language doc (mostly, hopefully)

Still TODO:

  • The signature-level grammar should be separated from the base-level declarations (both in terms of non-terminals and .sdf-files)
  • The syntax rules for many of the constructs need much refinement (based on mutual feedback from user experience)
  • There's probably a very nice, regular (in the non-grammar sense of the word) grammar hidden somewhere beneath the mess...
Location:
trunk/metaxa/src
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/metaxa/src/Magnolia/BaseExtMix.sdf

    r450 r458  
    3131            MorphClause           => MorphClause[[Ctx0]]
    3232            Morphism              => Morphism[[Ctx0]]
    33             ImplExpr              => ImplExpr[[Ctx0]]
    3433            ConceptExpr           => ConceptExpr[[Ctx0]]
    3534            WithClause            => WithClause[[Ctx0]]
    3635            GuardClause           => GuardClause[[Ctx0]]
    3736            Attribute             => Attribute[[Ctx0]]
    38             SubClause             => SubClause[[Ctx0]]
    3937            AttrClause            => AttrClause[[Ctx0]]
    4038            DeclDeclarative       => DeclDeclarative[[Ctx0]]
    41             DeclName              => DeclName[[Ctx0]]
    4239            DeclClause            => DeclClause[[Ctx0]]
     40            TypeIdentifier        => TypeIdentifier[[Ctx0]]
     41            TypeName              => TypeName[[Ctx0]]
    4342            TypeDeclarative       => TypeDeclarative[[Ctx0]]
    44             TypeName              => TypeName[[Ctx0]]
    4543            TypeClause            => TypeClause[[Ctx0]]
    4644            VarName               => VarName[[Ctx0]]
     45            VarIdentifier         => VarIdentifier[[Ctx0]]
    4746            VarClause             => VarClause[[Ctx0]]
    4847            ParamMode             => ParamMode[[Ctx0]]
    4948            ProcedureParam        => ProcedureParam[[Ctx0]]
    5049            FunctionParam         => FunctionParam[[Ctx0]]
    51             TypeParam             => TypeParam[[Ctx0]]
    5250            ProcedureParamList    => ProcedureParamList[[Ctx0]]
    5351            FunctionParamList     => FunctionParamList[[Ctx0]]
    54             TypeParamList         => TypeParamList[[Ctx0]]
     52            AxiomIdentifier       => AxiomIdentifier[[Ctx0]]
    5553            AxiomName             => AxiomName[[Ctx0]]
    5654            AxiomClause           => AxiomClause[[Ctx0]]
    57             PredName              => PredName[[Ctx0]]
    5855            PredClause            => PredClause[[Ctx0]]
     56            FunIdentifier         => FunIdentifier[[Ctx0]]
    5957            ExprDeclarative       => ExprDeclarative[[Ctx0]]
    6058            FunClause             => FunClause[[Ctx0]]
     59            ProcIdentifier        => ProcIdentifier[[Ctx0]]
    6160            StatDeclarative       => StatDeclarative[[Ctx0]]
    6261            ProcClause            => ProcClause[[Ctx0]]
     62            SubClause             => SubClause[[Ctx0]]
    6363            DeclBody              => DeclBody[[Ctx0]]
    6464            Decl                  => Decl[[Ctx0]]
     
    9494            Program               => Program[[Ctx0]]
    9595            Type                  => Type[[Ctx0]]
     96            ImplExpr              => ImplExpr[[Ctx0]]
    9697            Expr                  => Expr[[Ctx0]] ]
  • trunk/metaxa/src/Magnolia/Core/Declarations.sdf

    r457 r458  
    6868  context-free syntax
    6969
    70     StatDeclarative SubClause* BlockStat
     70    Modifier* StatDeclarative SubClause* BlockStat
    7171        -> BraceDecl
    7272                {cons("DefDecl")}
    7373
    74     ExprDeclarative SubClause* "=" Expr ";"
     74    Modifier* ExprDeclarative SubClause* "=" Expr ";"
    7575        -> SemiDecl
    7676                {cons("DefDecl")}
    7777
    78     TypeDeclarative SubClause* "=" Type ";"
     78    Modifier* TypeDeclarative SubClause* "=" Type ";"
    7979        -> Decl
    8080                {cons("DefDecl")}
    8181
    82     DeclDeclarative SubClause* DeclBody
     82    Modifier* DeclDeclarative SubClause* DeclBody
    8383        -> BraceDecl
    8484                {cons("DefDecl")}
     
    9292        "external" -> SubClause
    9393       
     94        "default" -> Modifier
     95       
     96        "abstract" -> Modifier
     97       
    9498%%% Procedure Declarations
    9599  sorts
    96     ProcClause ProcName
    97 
    98   context-free syntax
    99 
    100     "procedure" ProcName ProcedureParamList
     100    ProcClause ProcName ProcIdentifier
     101
     102  context-free syntax
     103
     104    "procedure" ProcIdentifier ProcedureParamList
    101105        -> ProcClause
    102106                {cons("ProcClause")}
     
    104108    ProcClause -> StatDeclarative
    105109
    106     Name -> ProcName
    107 
    108     "_=_" -> ProcName {cons("Assign")}
     110    Identifier -> ProcIdentifier
     111
     112        Name -> ProcName
     113       
     114    "_=_" -> ProcIdentifier {cons("Assign")}
    109115
    110116  lexical restrictions
     
    115121%%% Function Declarations
    116122  sorts
    117     FunClause FunName
    118 
    119   context-free syntax
    120 
    121     "function" FunName FunctionParamList ":" Type
     123    FunClause FunName FunIdentifier
     124
     125  context-free syntax
     126
     127    "function" FunIdentifier FunctionParamList ":" Type
    122128        -> FunClause                    {cons("FunClause")}
    123129
    124130    FunClause -> ExprDeclarative
    125131
    126     Name -> FunName
    127 
     132        Identifier -> FunIdentifier
     133       
     134        Name -> FunName
     135       
    128136  lexical restrictions
    129137
     
    136144  context-free syntax
    137145
    138     "predicate" PredName FunctionParamList
     146    "predicate" FunIdentifier FunctionParamList
    139147        -> PredClause                   {cons("PredClause")}
    140148
    141149    PredClause -> ExprDeclarative
    142150
    143     Name -> PredName
    144 
    145151  lexical restrictions
    146152
     
    150156%%% Axiom Declarations
    151157  sorts
    152     AxiomClause AxiomName
    153 
    154   context-free syntax
    155 
    156     "axiom" AxiomName FunctionParamList
     158    AxiomClause AxiomName AxiomIdentifier
     159
     160  context-free syntax
     161
     162    "axiom" Identifier FunctionParamList
    157163        -> AxiomClause                  {cons("AxiomClause")}
    158164
    159     "theorem" AxiomName FunctionParamList
     165    "theorem" Identifier FunctionParamList
    160166        -> AxiomClause                  {cons("AxiomClause")}
    161167
    162     "proof" AxiomName FunctionParamList
     168    "proof" Identifier FunctionParamList
    163169        -> AxiomClause                  {cons("AxiomClause")}
    164170
     
    166172
    167173    Name -> AxiomName
     174   
     175    Identifier -> AxiomIdentifier
    168176
    169177  lexical restrictions
     
    181189  context-free syntax
    182190
    183     "(" {TypeParam ","}* ")"    -> TypeParamList        {cons("Dummy")}
     191   %% "(" {TypeParam ","}* ")"  -> TypeParamList        {cons("Dummy")}
    184192
    185193    "(" {FunctionParam ","}* ")"-> FunctionParamList    {cons("Dummy")}
     
    187195    "(" {ProcedureParam ","}* ")"-> ProcedureParamList  {cons("Dummy")}
    188196
    189     Type                        -> TypeParam            {cons("TypeExprParam")}
    190 
    191     Type Identifier             -> TypeParam            {cons("TypeExprParam")}
    192 
    193     "type"                      -> TypeParam            {cons("AnonTypeParam")}
    194 
    195     "type" Identifier           -> TypeParam            {cons("TypeParam")}
    196 
    197     "type" TypeParamList        -> TypeParam            {cons("AnonTypePParam")}
    198 
    199     "type" Identifier TypeParamList -> TypeParam        {cons("TypePParam")}
    200 
    201     Identifier ":" Type         -> FunctionParam        {cons("Param")}
    202 
    203     ParamMode Identifier ":" Type -> ProcedureParam     {prefer, cons("Param")}
     197   %% Type                      -> TypeParam            {cons("TypeExprParam")}
     198
     199   %% Type Identifier           -> TypeParam            {cons("TypeExprParam")}
     200
     201   %% "type"                    -> TypeParam            {cons("AnonTypeParam")}
     202
     203   %% "type" Identifier         -> TypeParam            {cons("TypeParam")}
     204
     205   %% "type" TypeParamList      -> TypeParam            {cons("AnonTypePParam")}
     206
     207   %% "type" Identifier TypeParamList -> TypeParam      {cons("TypePParam")}
     208
     209    VarIdentifier ":" Type              -> FunctionParam        {cons("Param")}
     210
     211    ParamMode VarIdentifier ":" Type -> ProcedureParam  {prefer, cons("Param")}
    204212
    205213    "obs"                       -> ParamMode            {cons("Obs")}
     
    225233%%% Variables
    226234
    227   sorts VarClause VarName
    228 
    229   context-free syntax
    230 
    231     "var" VarName ":" Type -> VarClause {cons("VarClause")}
     235  sorts VarClause VarIdentifier VarName
     236 
     237  context-free syntax
     238
     239    "var" VarIdentifier ":" Type -> VarClause {cons("VarClause")}
    232240
    233241    VarClause -> ExprDeclarative
    234242
    235     Name -> VarName
    236 
     243        Identifier -> VarIdentifier
     244       
     245        Name -> VarName
     246       
    237247  lexical restrictions
    238248
     
    242252
    243253  sorts
    244         TypeName TypeClause
    245 
    246   context-free syntax
    247 
    248     "type" TypeName     -> TypeClause {cons("TypeClause")}
    249 
    250     Name -> TypeName
     254        TypeClause TypeName TypeIdentifier
     255
     256  context-free syntax
     257
     258    "type" TypeIdentifier       -> TypeClause {cons("TypeClause")}
    251259
    252260    TypeClause -> TypeDeclarative
    253261
     262        Name -> TypeName
     263       
     264        Identifier -> TypeIdentifier
     265       
    254266  lexical restrictions
    255267
     
    259271
    260272  sorts
    261         DeclName DeclClause
    262 
    263   context-free syntax
    264 
    265     "concept" DeclName SubClause* "=" ConceptExpr               -> Decl {cons("ConceptClause")}
    266 %%    "theorem" DeclName                -> DeclClause {cons("ConceptClause")}
    267     "implementation" DeclName "on" ConceptExpr "defines"        -> DeclClause {cons("ImplClause")}
    268     "signature" DeclName        -> DeclClause {cons("SignatureClause")}
     273         DeclClause
     274
     275  context-free syntax
     276
     277    Modifier* "concept" Identifier SubClause* "=" ConceptExpr           -> Decl {cons("ConceptClause")}
     278%%    "theorem" Identifier              -> DeclClause {cons("ConceptClause")}
     279    Modifier* "implementation" Identifier SubClause* "=" ImplExpr -> Decl {cons("ImplClause")}
    269280 
    270         "library" DeclName SubClause* "=" ImplExpr      -> Decl {cons("Library")}
    271 
    272     Identifier -> DeclName
    273 
     281        Modifier* "library" Identifier SubClause* "=" ImplExpr  -> Decl {cons("Library")}
     282
     283    Modifier* "concept" Identifier SubClause* DeclBody          -> Decl {deprecated("Add '=' before body"), cons("ConceptClause")}
     284
     285    Modifier* "implementation" Identifier SubClause* ImplExpr -> Decl {deprecated("Add '=' before body"), cons("ImplClause")}
     286 
    274287    DeclClause -> DeclDeclarative
    275288
     
    278291    "concept"           -/- [A-Za-z\_\$0-9]
    279292%%    "theorem"         -/- [A-Za-z\_\$0-9]
    280     "module"            -/- [A-Za-z\_\$0-9]
    281     "signature"         -/- [A-Za-z\_\$0-9]
     293    "implementation"            -/- [A-Za-z\_\$0-9]
     294    "library"           -/- [A-Za-z\_\$0-9]
    282295
    283296%%% Declaration Attributes
     
    315328    "requires" {ConceptExpr ","}+ ";" -> Decl   {cons("Requires")}
    316329
     330%% TODO: What are these supposed to be?
     331        "preserve" DeclBody -> Decl {todo("Grammar needs refinement")}
     332       
     333        "congruence" DeclBody -> Decl {todo("Grammar needs refinement")}
     334       
     335       
    317336
    318337  lexical restrictions
     
    341360
    342361
    343     "satisfaction" DeclName "=" ConceptExpr WithClause? "models" ConceptExpr ";" -> Decl {cons("ModelsImpl")}
     362    "satisfaction" Identifier SubClause* "=" ConceptExpr WithClause? "models" ConceptExpr -> Decl {cons("ModelsImpl")}
     363
     364    "satisfaction" Identifier SubClause* "=" "on" ConceptExpr WithClause? "models" ConceptExpr -> Decl {deprecated("Drop 'on'"), cons("ModelsImpl")}
    344365   
    345366    "with" ImplExpr -> WithClause {cons("WithClause")}
    346367
    347     DeclName -> ConceptExpr {cons("Concept")}
     368    Name -> ConceptExpr {cons("Concept")}
    348369
    349370    DeclBody -> ConceptExpr {cons("ConceptBody")}
    350 
     371   
    351372    "signature" ConceptExpr -> ConceptExpr {cons("SignatureOf")}
    352373
    353374    ConceptExpr Morphism -> ConceptExpr {cons("MorphedConcept")}
    354375
    355     DeclName -> ImplExpr  {cons("Impl")}
     376    Name -> ImplExpr  {cons("Impl")}
    356377
    357378    ImplExpr Morphism -> ImplExpr  {cons("ImplMorph")}
     
    359380    DeclBody -> ImplExpr  {cons("ImplBody")}
    360381   
     382    %% TODO: Needs refinement
     383   
    361384    "external" Identifier Name "defines" ImplExpr -> ImplExpr {cons("ExternalLib")}
    362385
     386    "external" Identifier Name "on" ConceptExpr "defines" ImplExpr -> ImplExpr {cons("ExternalLib")}
     387
     388    "on" ConceptExpr "defines" ImplExpr -> ImplExpr {cons("OnDefines")}
     389   
    363390%% Morphisms
    364391context-free syntax
     
    368395    "morphism" MorphClause -> SubClause {cons("Morphism")}
    369396
    370     "protect" FunClause "by" Expr -> Morphism   {cons("Protect")}
     397        "{" MorphClause* "}" -> MorphClause {todo("clean up syntax for list of morph clauses"), cons("ImplMorphism")}
     398       
     399        "{" (MorphClause ";")* "}" -> MorphClause {todo("clean up syntax for list of morph clauses"), cons("ImplMorphism")}
    371400
    372401    "[" {MorphClause ","}* "]" -> Morphism {cons("Morphisms")}
    373402
    374     DeclName "=>" DeclName -> MorphClause  {cons("Rename")}
     403    Name "=>" Name -> MorphClause  {cons("Rename")}
    375404
    376405    TypeClause "=" Type -> MorphClause  {cons("Morphism")}
     
    380409    PredClause "=" Expr -> MorphClause  {cons("Morphism")}
    381410
    382     "protect" FunClause "by" Expr -> MorphClause        {cons("Protect")}
    383 
    384     "protect" FunClause "by" Expr -> SubClause  {cons("Protect")}
    385 
     411    "protect" FunClause "guard" Expr -> Morphism        {cons("Protect")}
     412
     413    "protect" FunClause "guard" Expr -> MorphClause     {cons("Protect")}
     414
     415    "protect" FunClause "guard" Expr -> SubClause       {cons("Protect")}
     416
     417    "protect" FunClause "by" Expr -> Morphism   {deprecated("Use 'guard' instead of 'by'"),cons("Protect")}
     418
     419    "protect" FunClause "by" Expr -> MorphClause        {deprecated("Use 'guard' instead of 'by'"),cons("Protect")}
     420
     421    "protect" FunClause "by" Expr -> SubClause  {deprecated("Use 'guard' instead of 'by'"),cons("Protect")}
     422
     423%% ImplExpr
     424context-free syntax
     425
     426        ImplExpr "@" ImplExpr -> ImplExpr {left, cons("At")}
     427        ImplExpr "@@" ImplExpr -> ImplExpr {left, cons("AtAt")}
     428        ImplExpr "*" ImplExpr -> ImplExpr {left, cons("Star")}
     429        ImplExpr "**" ImplExpr -> ImplExpr {left, cons("StarStar")}
     430        ImplExpr "+" ImplExpr -> ImplExpr {left, cons("Plus")}
     431        ImplExpr "++" ImplExpr -> ImplExpr {left, cons("PlusPlus")}
     432        ImplExpr "times" ImplExpr -> ImplExpr {left, cons("Times")}
     433        "(" ImplExpr ")" -> ImplExpr {bracket}
     434
     435        ConceptExpr "@" ConceptExpr -> ConceptExpr {left, cons("At")}
     436        ConceptExpr "@@" ConceptExpr -> ConceptExpr {left, cons("AtAt")}
     437        ConceptExpr "*" ConceptExpr -> ConceptExpr {left, cons("Star")}
     438        ConceptExpr "**" ConceptExpr -> ConceptExpr {left, cons("StarStar")}
     439        ConceptExpr "+" ConceptExpr -> ConceptExpr {left, cons("Plus")}
     440        ConceptExpr "++" ConceptExpr -> ConceptExpr {left, cons("PlusPlus")}
     441        ConceptExpr "times" ConceptExpr -> ConceptExpr {left, cons("Times")}
     442        "(" ConceptExpr ")" -> ConceptExpr {bracket}
     443       
  • trunk/metaxa/src/Magnolia/Core/Expressions.sdf

    r425 r458  
    6969%%% Value Construction
    7070
    71     Type "$" "{" {InitSpec ","}* "}" -> Expr {cons("Struct"), selectable}
     71    Type "$" "{" {InitSpec ","}* "}" -> Expr {cons("Struct"), selectable, todo("With or without '$'?")}
     72
     73    Type "{" {InitSpec ","}* "}" -> Expr {cons("Struct"), selectable, todo("With or without '$'?")}
    7274
    7375    Identifier ":=" Expr -> InitSpec {cons("Field")}
  • trunk/metaxa/src/Magnolia/Core/Identifiers.sdf

    r425 r458  
    3636  lexical syntax
    3737
    38     [A-Za-z][A-Za-z\_\$0-9]* -> ID
     38    [A-Za-z][A-Za-z\_\$\#0-9]* -> ID
    3939
    4040    "_" -> NOID
  • trunk/metaxa/src/Magnolia/CoreMix.sdf

    r450 r458  
    33          [ MorphClause        => MorphClause[[Ctx0]]
    44            Morphism           => Morphism[[Ctx0]]
    5             ImplExpr           => ImplExpr[[Ctx0]]
    65            ConceptExpr        => ConceptExpr[[Ctx0]]
    76            WithClause         => WithClause[[Ctx0]]
    87            GuardClause        => GuardClause[[Ctx0]]
    98            Attribute          => Attribute[[Ctx0]]
    10             SubClause          => SubClause[[Ctx0]]
    119            AttrClause         => AttrClause[[Ctx0]]
    1210            DeclDeclarative    => DeclDeclarative[[Ctx0]]
    13             DeclName           => DeclName[[Ctx0]]
    1411            DeclClause         => DeclClause[[Ctx0]]
     12            TypeIdentifier     => TypeIdentifier[[Ctx0]]
     13            TypeName           => TypeName[[Ctx0]]
    1514            TypeDeclarative    => TypeDeclarative[[Ctx0]]
    16             TypeName           => TypeName[[Ctx0]]
    1715            TypeClause         => TypeClause[[Ctx0]]
    1816            VarName            => VarName[[Ctx0]]
     17            VarIdentifier      => VarIdentifier[[Ctx0]]
    1918            VarClause          => VarClause[[Ctx0]]
    2019            ParamMode          => ParamMode[[Ctx0]]
    2120            ProcedureParam     => ProcedureParam[[Ctx0]]
    2221            FunctionParam      => FunctionParam[[Ctx0]]
    23             TypeParam          => TypeParam[[Ctx0]]
    2422            ProcedureParamList => ProcedureParamList[[Ctx0]]
    2523            FunctionParamList  => FunctionParamList[[Ctx0]]
    26             TypeParamList      => TypeParamList[[Ctx0]]
     24            AxiomIdentifier    => AxiomIdentifier[[Ctx0]]
    2725            AxiomName          => AxiomName[[Ctx0]]
    2826            AxiomClause        => AxiomClause[[Ctx0]]
    29             PredName           => PredName[[Ctx0]]
    3027            PredClause         => PredClause[[Ctx0]]
     28            FunIdentifier      => FunIdentifier[[Ctx0]]
    3129            ExprDeclarative    => ExprDeclarative[[Ctx0]]
    3230            FunClause          => FunClause[[Ctx0]]
     31            ProcIdentifier     => ProcIdentifier[[Ctx0]]
    3332            StatDeclarative    => StatDeclarative[[Ctx0]]
    3433            ProcClause         => ProcClause[[Ctx0]]
     34            SubClause          => SubClause[[Ctx0]]
    3535            DeclBody           => DeclBody[[Ctx0]]
    3636            Decl               => Decl[[Ctx0]]
     
    6666            ModuleHead         => ModuleHead[[Ctx0]]
    6767            Program            => Program[[Ctx0]]
    68             Type               => Type[[Ctx0]] ]
     68            Type               => Type[[Ctx0]]
     69            ImplExpr           => ImplExpr[[Ctx0]] ]
  • trunk/metaxa/src/gen-tbl

    r445 r458  
    1 if [ -d /home/anya/eclipse/ ]; then
    2         ECLIPSE=/home/anya/eclipse
    3 elif [ -d /usr/local/eclipse/ ]; then
    4         ECLIPSE=/usr/local/eclipse
     1#! /bin/sh
     2FRAGMENT=plugins/rascal_fragment_linux_0.1.6
     3
     4if [ -d $HOME/eclipse/$FRAGMENT ]; then
     5        FRAGMENT=$HOME/eclipse/$FRAGMENT
     6elif [ -d $HOME/magnolia/eclipse/$FRAGMENT ]; then
     7        FRAGMENT=$HOME/magnolia/eclipse/$FRAGMENT
     8elif [ -d /usr/local/eclipse/$FRAGMENT ]; then
     9        FRAGMENT=/usr/local/eclipse/$FRAGMENT
     10else
     11        echo Unable to find rascal-fragment
     12        exit 1
    513fi
    614
    7 FRAGMENT=$ECLIPSE/plugins/rascal_fragment_linux_0.1.6
    815
    916export LD_LIBRARY_PATH=$FRAGMENT/installed/lib/
Note: See TracChangeset for help on using the changeset viewer.