Skip to content

Examples

heartleth edited this page Oct 7, 2023 · 3 revisions

Number

10진수 가능

number.lan

PART main
    RULE number ?*sign |>*numeric
END

dictionary.dict

PART numeric
0
1
2
3
4
5
6
7
8
9

PART sign
+ pos
- neg

Base N Number

2, 8, 10, 16진수 가능

number.lan

PART main
    RULE bnn $BasedNumber( 2 )
END

PART BasedNumber
    RULE number ?*sign |>*numeric[:0=:0]
END

dictionary.dict

PART numeric
0 2
1 2

0 8
1 8
2 8
3 8
4 8
5 8
6 8
7 8

0 10
1 10
2 10
3 10
4 10
5 10
6 10
7 10
8 10
9 10

0 16
1 16
2 16
3 16
4 16
5 16
6 16
7 16
8 16
9 16
A 16
B 16
C 16
D 16
E 16
F 16

PART sign
...

Molecule

chemistry.lan

PART main
    RULE molecule $Molecule
END

PART Molecule 1
    # :0 | p
    RULE s      [:0=p]*conj $Combine ?$Molecule( p )
END

PART Combine 2
    # :0 | Ion
    # :1 | Is Starting

    IF :1 0
        RULE fold   ?$Number $SubstanceN $Combine( :0 false )
        RULE sub    ?$Number $SubstanceN ?*Ion
    END
    IF :1 false
        RULE fold   $SubstanceN $Combine( :0 false )
        RULE sub    $SubstanceN ?*Ion
    END
END

PART SubstanceN
    RULE substance  $Substance ?$Number
END

PART Substance
    RULE elem       *elements
    RULE embed      (-left $Combine )-right
END

PART Number
    RULE n  |>*numeric
END

dictionary.dict

PART elements
H
He
Li
Be
...

PART conj
+
-->

PART Ion
(+)
(2+)
(3+)

(-)
(2-)
(3-)

PART numeric
...
Clone this wiki locally