Do markup languages ​​have the equivalent concept of `semantics` that you can find in C or C++?

Maybe I miss something, but do the so called markup languages have the equivalent concept of semantics that you can find in C or C++?

Judging from how you parse the language, you don’t really have too many options, there isn’t too much context, you just parse your tokens and apply them to the source code.

I’m tempted to say that not only semantics doesn’t exist in this case, but this only happens in markup languages: am I right?

7

Common markup languages and common programming languages are indistinguishable in that they have both syntax and semantics. They differ only in that the purpose of a programming language is to generate executable code for a processor, while the purpose of a markup language is to generate declarative data for a display engine.

Both have a lexical structure. They are made up of tokens like words and numbers and punctuation.

Both have a syntactical structure. The tokens can be arranged in many different ways, and some arrangements are valid while others are not.

Both have a semantic structure. The tokens have meaning, some being predefined and some user-defined, and the way that tokens are arranged has meaning.

If we take the following code fragment:

<div class="yolo">Hello world</div>

The tokens div, class and the angle brackets have pre-defined meanings. The token “yolo” is a string which provides a user-defined name for the div. The angle brackets separate the markup from the text. These are semantic observations.

For both, the parser phase of the compiler stops at the same point, when it has generated a suitable internal representation (such as an AST).

The next phase for a programming language is to generate code. The next phase for a markup language could be to generate a DOM. That phase is dependent on the the semantics, but not part of it.

5

A language is defined (a) by its syntax which includes the grammar and the lexical structure or vocabulary, and (b) the semantics, which is the meaning. In C, the snippet a + 1 has the meaning “add the contents of variable a and the integer 1”. In HTML, the snippet <p>foo bar</p> has the meaning “a paragraph element containing the text foo bar”.

So markup languages do have semantics (i.e. a meaning). However, semantics have nothing to do with parsing. During parsing, the input is broken up according to the lexical structure. These tokens are then arranged according to the grammar of the language. E.g. the English snippet you asked a question might be arranged as

subject: 'you',
predicate: (verb: 'ask',
            tense: past,
            object: (article: indefinite,
                     noun: 'question'))

This structure helps figuring out the meaning, but it’s not the same as the actual meaning.

There can also be well-formed sentences that do not have valid semantics. For example, the above C example a + 1 makes no sense if a holds a struct instead of a numeric type. In English, Colorless green ideas sleep furiously would be an example of a well-formed, but nonsensical sentence.

10

Markup languages most definitely have syntax (specific sequences of characters that defines tokens) and semantics (meaning to be applied to parsed content). You can’t really have a language without both. You might possibly be able to argue about XML (semantics are really specific to a particular format, making each a DSL), but you can’t possibly argue about HTML.

What HTML lacks is EXPRESSION STATEMENTS or variables. Without adding in CSS there’s no way to make it do a calculation by itself. This means it’s not able to perform any calculations and is limited to giving semantics to content — it can neither create or modify content on it’s own.

Note that the way you typically add/modify html content on the fly is only possible because html has semantics — in particular, you can say: this bunch of text is a computer program in language x, run it (where X is generally javascript).

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật