예제 #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}");
            }
        }
예제 #2
0
 public Object(SourceInfo sourceInfo, String identifier, IList <Field> fields) : base(sourceInfo)
 {
     this.Identifier = identifier;
     this.Fields     = fields;
 }
예제 #3
0
파일: Element.cs 프로젝트: bgrevelt/biPage
 public Element(SourceInfo sourceinfo) : base(sourceinfo)
 {
 }
예제 #4
0
 public FieldType(SourceInfo sourceInfo) : base(sourceInfo)
 {
 }
예제 #5
0
 public Enumerator(SourceInfo sourceinfo, String name, String value) : base(sourceinfo)
 {
     this.Name           = name;
     this.Original_value = value;
 }
예제 #6
0
 public Parser(SourceInfo sourceInfo, String name, IList <AST.Element> elements) : base(sourceInfo)
 {
     this.Elements = elements;
     this.Name     = name;
 }
예제 #7
0
 public ASTNode(SourceInfo sourceInfo)
 {
     this.SourceInfo = sourceInfo;
 }
예제 #8
0
 public IMultiplier(SourceInfo sourceInfo) : base(sourceInfo)
 {
 }
예제 #9
0
 public Enumeration(SourceInfo sourceInfo, String identifier, FieldType type, IList <Enumerator> enumerators) : base(sourceInfo)
 {
     this.Identifier  = identifier;
     this.Enumerators = enumerators;
     this.Type        = type;
 }