Skip to content

Instantly share code, notes, and snippets.

@mrprofessor
Created May 4, 2017 09:52
Show Gist options
  • Save mrprofessor/7b8df3f00c75ef2ac67bffd0a20e983c to your computer and use it in GitHub Desktop.
Save mrprofessor/7b8df3f00c75ef2ac67bffd0a20e983c to your computer and use it in GitHub Desktop.
grammar org.xtext.example.demo.Demo with org.eclipse.xtext.common.Terminals
generate demo "http://www.xtext.org/example/demo/Demo"
Model :
(elements+=Type)*;
Type:
DataType //| Statement | Condition
;
//Datatype Grammar
DataType:
Arithmatic | Character | Bit | Pointer | Label | Entry
;
//Rules for Arithmatic declaration.
Arithmatic:
Integer | HwordInteger | Logical | HwordLogical | Byte
;
Integer:
"DCL" (name=ID("("INT")")?) "INTEGER" ";"
;
HwordInteger:
"DCL" ("CI")? (name=ID("("INT")")?) "HWORD_INTEGER" ";"
;
// Logical HwordLogical and Byte are yet to be defined.
Logical:
name=ID ";"
;
HwordLogical:
name=ID ";"
;
Byte:
name=ID ";"
;
//Rules for Character type Declaration
Character:
"DCL" (name=ID("("INT")")?) "CHAR" ";"
;
// Rules for BIT type
Bit:
name=ID ";"
;
// Rules for Pointer type
Pointer:
name=ID ";"
;
// Rules for Label type
Label:
name=ID ";"
;
// Rules for Entry type
Entry:
name=ID ";"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment