Esempio n. 1
0
        private FieldType ParseType(String type, SourceInfo sourceInfo)
        {
            var type_only = type.TrimEnd("0123456789".ToCharArray());

            uint.TryParse(type.TrimStart("abcdefghijklmnopqrstuvwxyz".ToCharArray()), out uint size);
            Debug.Assert(new HashSet <String> {
                "int", "i", "uint", "u", "float", "f", "bool", "ascii_string", "utf8_string"
            }.Contains(type_only));

            switch (type_only)
            {
            case "int":
            case "i":
                return(new AST.FieldTypes.Signed(sourceInfo, size));

            case "uint":
            case "u":
                return(new AST.FieldTypes.Unsigned(sourceInfo, size));

            case "float":
            case "f":
                return(new AST.FieldTypes.Float(sourceInfo, size));

            case "bool":
                return(new AST.FieldTypes.Boolean(sourceInfo));

            case "ascii_string":
                return(new AST.FieldTypes.AsciiString(sourceInfo));

            case "utf8_string":
                return(new AST.FieldTypes.Utf8String(sourceInfo));

            default:
                // This indicates an error in our grammar or an error in ANTLR
                throw new ArgumentException($"Unrecoginized fieldtype {type}");
            }
        }
Esempio n. 2
0
 public Object(SourceInfo sourceInfo, String identifier, IList <Field> fields) : base(sourceInfo)
 {
     this.Identifier = identifier;
     this.Fields     = fields;
 }
Esempio n. 3
0
 public Element(SourceInfo sourceinfo) : base(sourceinfo)
 {
 }
Esempio n. 4
0
 public FieldType(SourceInfo sourceInfo) : base(sourceInfo)
 {
 }
Esempio n. 5
0
 public Enumerator(SourceInfo sourceinfo, String name, String value) : base(sourceinfo)
 {
     this.Name           = name;
     this.Original_value = value;
 }
Esempio n. 6
0
 public Parser(SourceInfo sourceInfo, String name, IList <AST.Element> elements) : base(sourceInfo)
 {
     this.Elements = elements;
     this.Name     = name;
 }
Esempio n. 7
0
 public ASTNode(SourceInfo sourceInfo)
 {
     this.SourceInfo = sourceInfo;
 }
Esempio n. 8
0
 public IMultiplier(SourceInfo sourceInfo) : base(sourceInfo)
 {
 }
Esempio n. 9
0
 public Enumeration(SourceInfo sourceInfo, String identifier, FieldType type, IList <Enumerator> enumerators) : base(sourceInfo)
 {
     this.Identifier  = identifier;
     this.Enumerators = enumerators;
     this.Type        = type;
 }