Skip to content
Snippets Groups Projects
Select Git revision
3 results Searching

index.md

Blame
  • RelAstBase.parser 2.92 KiB
    Program goal =
    	type_decls.t relations.r {: return new Program(t, r); :}
    	| STRING_LITERAL STAR {: return new Program(); :}
    	;
    
    List type_decls =
    	/* empty */ {: return new List(); :}
    	| type_decls.l type_decl.d {: return l.add(d); :}
    	;
    
    TypeDecl type_decl =
    	ID type_decl_super.s components_opt.c SCOL
    	{: return new TypeDecl(ID, false, s, c); :}
    	| ABSTRACT ID type_decl_super.s components_opt.c SCOL
    	{: return new TypeDecl(ID, true, s, c); :}
    	;
    
    Opt type_decl_super =
    	/* empty */ {: return new Opt(); :}
    	| COL s_type_use.u {: return new Opt(u); :}
    	;
    
    SimpleTypeUse s_type_use =
    	ID {: return new SimpleTypeUse(ID); :}
    	;
    
    TypeUse type_use =
    	s_type_use.u {: return u; :}
    	| parameterized_type_use.p {: return p; :}
    	;
    ParameterizedTypeUse parameterized_type_use =
    	ID LT type_use_list.l GT {: return new ParameterizedTypeUse(ID, l); :}
    	;
    List type_use_list =
    	type_use.u {: return new List().add(u); :}
    	| type_use_list.l COMMA type_use.u {: return l.add(u); :}
    	;
    
    List components_opt =
    	/* empty */ {: return new List(); :}
    	| ASSIGN components.l {: return l; :}
    	;
    
    List components =
    	{: return new List(); :}
    	| components.l component.c {: return l.add(c); :}
    	;
    
    Component component =
    	ID COL s_type_use.u {: return new NormalComponent(ID, u); :}
    	| s_type_use.u {: return new NormalComponent(u.getID(), u); :}
    	// List
    	| ID COL s_type_use.u STAR {: return new ListComponent(ID, u); :}
    	| s_type_use.u STAR {: return new ListComponent(u.getID(), u); :}
    	// Opt
    	| LBRACKET ID COL s_type_use.u RBRACKET {: return new OptComponent(ID, u); :}
    	| LBRACKET s_type_use.u RBRACKET {: return new OptComponent(u.getID(), u); :}
    	// NTA
    	| SLASH ID COL s_type_use.u SLASH {: return new NTAComponent(ID, u); :}
    	| SLASH s_type_use.u SLASH {: return new NTAComponent(u.getID(), u); :}
    	// NTA Token (same as NTA)
    	| SLASH LT ID COL s_type_use.u GT SLASH {: return new NTAComponent(ID, u); :}
    	| SLASH LT s_type_use.u GT SLASH {: return new NTAComponent(u.getID(), u); :}
    	// Token
    	| LT ID COL type_use.u GT {: return new TokenComponent(ID, u); :}
    	| LT ID GT {: return new TokenComponent(ID, new SimpleTypeUse("String")); :}
    	;
    
    List relations =
    	/* empty */ {: return new List(); :}
    	| relations.l relation.r {: return l.add(r); :}
    	;
    
    Relation relation =
    	RELATION relation_comp.l direction relation_comp.r SCOL
    	{: return new Relation(l, direction, r); :}
    	;
    
    RelationComponent relation_comp =
    	// One
    	s_type_use.u DOT ID {: return new OneRelationComponent(ID, u); :}
    	| s_type_use.u {: return new OneRelationComponent("", u); :}
    	// Optional
    	| s_type_use.u DOT ID QUESTION_MARK {: return new OptionalRelationComponent(ID, u); :}
    	| s_type_use.u QUESTION_MARK {: return new OptionalRelationComponent("", u); :}
    	// Many
    	| s_type_use.u DOT ID STAR {: return new ManyRelationComponent(ID, u); :}
    	| s_type_use.u STAR {: return new ManyRelationComponent("", u); :}
    	;
    
    Direction direction =
    	RIGHT {: return new RightDirection(); :}
    	| BIDIRECTIONAL {: return new Bidirectional(); :}
    	;